分类:
2014-04-12 14:28:53
原文地址:shell实战技巧5:自动登录多台远程主机查看进程是否正常 作者:yuhuohu
#!/sbin/sh logfile=/etc/chk/log/`date +%Y%m%d`.run.log if [ -f "$logfile" ]; then rm $logfile fi touch $logfile tail -f $logfile & for i in `cat /etc/chk/hosts.run.lst` do (sleep 10;echo "ps -ef | grep run |wc -l";sleep 3;echo exit;) | rlogin $i >/etc/chk/run.tmp tail -n 3 /etc/chk/run.tmp >> $logfile done rm /etc/chk/run.tmp kill `ps -f -u root | grep "tail -f $logfile" | awk '{print $2}'` >/dev/null exit |