linux shell工具集合

1)判断进程是否存在,如果不存在再执行启动命令,可以避免一个脚本同时启动多份

if [ $(ps -ef |grep  bastion_account.sh|grep -v grep|wc -l) -eq 0 ];then
    nohup sh bastion_account.sh &
fi

2)如何批量kill进程?

ps -ef|grep 'python' |grep -v grep| awk '{print $2}’ | xargs kill -9

3)查看端口

netstat -lnpt 查看服务
ss -e 查看所有的连接数

4)查看服务器有没有来源某个ip的连接

netstat -anpl |grep '192.168.10.15'

5)分析 access log慢请求

cat access.log | awk ' $1>0.5 {print $1,$12}'

6)查看服务状态

service --status-all