Crontab - Restart apache every 3 hours [closed]

你。 提交于 2019-12-08 19:47:41

问题


My server is currently suffering from some problems due to visitors lag and i think the best solution for it, is to restart apache every 2/3 hours or so
How can i do this through cronjob ?


回答1:


Why do you want to do this?If you are experiencing a specific problem with Apache.It Will definitely be more beneficial for you to have a look into the access/error logs, and make adjustments accordingly.Give us some more information and we can look into your logs and give you a more appropriate solution.

None the less heres the cron to restart apache.

0 */3 * * */ root/restart_apache > /dev/null 2>&1

/etc/init.d/httpd restart



回答2:


I can almost guarantee this 'fix' will not address your real issue. Why not post your Http.conf settings and a little info on your server resources (memory, cpus) and we might help fix your config issues.




回答3:


Instead of adding to the crontab of an individual user (root), I would add hacks like this to /etc/cron.d.

Change 'apache2' to whatever the init script is on debian.

echo '* */3 * * * root /etc/init.d/apache2 restart 2>&1 >/dev/null' > /etc/cron.d/apachesux


来源:https://stackoverflow.com/questions/12862576/crontab-restart-apache-every-3-hours

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!