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

运行定时程序:

crontab -e

   输入以下内容每隔5分钟检测一次

*/5 * * * * /root/test200_monitor.sh

 

posted @ 2013-04-05 13:07  shineme  阅读(365)  评论(0编辑  收藏  举报