|
以下一段代码,单独可执行,但添加到root的crontab中,问题出错,提示:cron.err crond[18689]: USER root pid 19071 cmd sh /usr/sbin/monitor.sh 2>&1
在/root/rcord中能看见'hello'和date值。
#!/bin/sh
source /etc/profile
PING=`/bin/ping -c 5 61.128.128.68|grep -v grep|grep '64 bytes' |wc -l`
if [ ${PING} -ne 0 ];then
echo 'hello' >> /root/record
date >> /root/record
exit 0
else
/etc/init.d/network restart
fi
sleep 10
PING2=`/bin/ping -c 5 61.128.128.68|grep -v grep|grep '64 bytes' |wc -l`
if [ ${PING2} -ne 0 ];then
echo 'boy' >> /root/record
exit 0
else
reboot
fi
|
|