[root@localhost ~]# crontab -e
0 6 * * * /sbin/reboot
20 6 * * * su -l root -c "/etc/runapache"
[root@localhost ~]# cat /etc/runapache
#!/bin/sh
#ssh 127.0.0.1 -p 5566 -l root
#sleep 3
apache_test=`ps -ef | grep '/usr/local/apache2/bin/httpd' | wc -l`
if [ $apache_test > 0 ]
then
/usr/local/apache2/bin/apachectl stop
sleep 5
/usr/local/apache2/bin/apachectl start
else
/usr/local/apache2/bin/apachectl start
fi
#echo "apache is stoped"
#sleep 3
#/usr/local/apache2/bin/apachectl start
#echo "apache is ok"
date >> /root/runapache_time.txt
[root@localhost ~]#
#如果不用su -l root -c 则/etc/runapache会以系统用户运行,apache确实重启,但是可能会有其他的错误!如某些模块必须以root来挂载!
阅读(1039) | 评论(0) | 转发(0) |