Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crontab - Restart apache every 3 hours [closed]

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 ?

like image 860
Osa Avatar asked Oct 12 '12 15:10

Osa


People also ask

Do I need to reload crontab?

No. As long as you use the crontab -e command to edit the file, when you save it, you'll get a 'New Crontab Installed' message.

Does crontab run automatically?

Cron reads the crontab (cron tables) for predefined commands and scripts. By using a specific syntax, you can configure a cron job to schedule scripts or other commands to run automatically.


Video Answer


1 Answers

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
like image 129
Wessel Avatar answered Oct 02 '22 15:10

Wessel