Automatic reboot Apache and Mysql every x min, possible?

Status
Not open for further replies.
10 comments
It is, using simple commands but sometimes it will kill the connections from clients even if the load is normal and if the time difference between the restarts is high, the server may become non-responsive and the restart command won't work.

The better idea is to trace out the exact problem and eradicate it.
If you think there isn't a problem and legitimate traffic increases the load, you should look to upgrade your server.
If you don't want to upgrade the server, write a script in a way which will monitor the load average every minute and will restart the services if load average reaches a certain limit stated in the script.

Here is a shell script to monitor load average on linux server but you need to add a code in it to restart the apache/mysql services.
 
You can do it using cron jobs.

Example, restart apache and mysql every hour:

Create a .sh file in this directory: /etc/cron.hourly

with the following code:
Code:
service httpd restart
service mysqld restart

But trust me, this won't help reducing the server load.
 
Hello, Thank you localhost.
I have created this file /etc/cron.hourly/automatic.sh with this code:
/etc/init.d/apache2 restart
service mysql restart
is there a way to know that this file is working correctly?
 
to reduce server load, it'd be better if you switch from apache to nginx or lighttpd. or maybe reversing nginx as a proxy to apache

restarting it over and over again will not help you much.
 
Status
Not open for further replies.
Back
Top