shell實用工具指令碼
阿新 • • 發佈:2018-11-10
在多臺機器上執行命令
#!/bin/bash
cat ip.txt|while read line
do
IP=`echo $line|awk '{print $1}'`
ssh -t -t [email protected]${IP}<<EOF
cd /home/work/temp
mkdir tt
cd tt
echo "aa" >> aa
exit
EOF
done
exit 0
#!/bin/bash for i in `cat ip.txt`;do echo $i; ssh $i "ps -ef|grep aa|grep -v grep|awk '{print\$2}'|xargs kill -9"; ssh $i "ps -ef|grep aa|grep -v grep|awk '{print\$2}'"; done;
監控檔案是否有Exception,有則重啟
#!/bin/bash set -x logpath=aa.log error_count=0 while [ 1 == 1 ] do tail -100 $logpath | grep -E '^java.lang.NullPointerException' >> monitor.log current_count=`wc -l monitor.log | awk '{print $1}'` if [ $current_count -gt $error_count ];then #執行命令 sleep 1 error_count=$current_count fi sleep 60 done