linux批量处理脚本

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!"

 

posted on 2023-04-25 10:36  哼着歌啦啦啦  阅读(71)  评论(0编辑  收藏  举报