1. 批量Kill
ps -ef | grep java| grep -v grep | awk '{print $2}'| xargs kill -9
2. 统计进程数
ps -ef| grep java | grep -v grep | awk '{print $2}'| wc
3. 批量打开防火墙端口
1 #!/bin/sh 2 ports=$1 3 echo "$ports" 4 IFS=' ' 5 read -ra ports_array <<< "$ports" 6 for i in "${ports_array[@]}" 7 do 8 echo "Open iptable port:$i" 9 firewall-cmd --zone=public --add-port=$i/tcp --permanent 10 done 11 12 systemctl stop firewalld 13 systemctl start firewalld 14 15 echo "OK!"
标签:脚本,ps,grep,批量,ef,linux,ports From: https://www.cnblogs.com/liwutao/p/17351912.html