linux定期判断网站可否打开
wget http://www.shopindream.de/200.php --timeout=2 c_monitor=$? rm -rf 200.php if [ ! $c_monitor = "0" ]; then echo "# Error Cannot open shopindream.de, time: " $(date +"%y-%m-%d %H:%M:%S") "restart lnmp.. " | mail -s "Website is offline." 747890528@qq.com /usr/local/php/sbin/php-fpm restart service mysql restart fi
然后是设定权限:
chmod 777 /root/test200_monitor.sh
运行定时程序:
输入以下内容每隔5分钟检测一次
vi /etc/crontab
*/5 * * * * /root/test200_monitor.sh
cat /etc/issue
Ubuntu 12.04.4 LTS \n \l
Ubuntu 12.04.4 LTS \n \l
修改vi /etc/crontab 不知为何,始终不能运行,后来修改的/etc/cron.d/anacron 才成功。