赞
踩
脚本放到root底下:vi my_watchdog.sh
写完添加.sh可执行权限
chmod 777 my_watchdog.sh
- #!/bin/sh
- #sleep 100
- DATE=`date +%Y-%m-%d-%H:%M:%S`
- tries=0
- echo --- my_watchdog start ---
- while [[ $tries -lt 5 ]]
- do
- if /bin/ping -c 1 8.8.8.8 >/dev/null
- then
- echo --- exit ---
- # echo $DATE OK >>my_watchdog.log
- exit 0
- fi
- tries=$((tries+1))
- sleep 10
- # echo $DATE tries: $tries >>my_watchdog.log
- done
-
- echo $DATE network restart >>my_watchdog.log
- /etc/init.d/network restart
- #echo $DATE reboot >>my_watchdog.log
- #reboot1
定时器放/etc/crontabs/root/
- */1 * * * * /root/my_watchdog.sh
-
- 0 0,4,8,12,16,20 * * * date -u +"%Y.%m.%d-%H:%M:%S" >/usr/data/time_backup
- 0,1,11,21,31,41,51 * * * * /usr/bin/set_kernel_timezone >/dev/null 2>&1
- 0 0,4,8,12,16,20 * * * /tmp/bw_backuo/do_bw_backup.sh
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。