Automatically restart Apache & MySQL

Status
Not open for further replies.

Sp32

Active Member
3,652
2009
1,326
340
This is pretty useful for people who are lazy and don't want to fix an underlying problem (usually a script that has a memory leak or if you want your website to run more efficient but don't want to pay more)

Login as root via SSH and do the following (These commands designed for Ubuntu/Linux with nano installed):

Code:
cd /
mkdir commands
cd commands
nano reboot.sh
Paste:
Code:
#!/bin/sh
/etc/init.d/apache2 restart
/etc/init.d/mysql restart
Code:
ctrl + x
y
return button/enter button
chmod +x reboot.sh
crontab -e
Paste:
Code:
59 * * * * /commands/reboot.sh
59 * * * * /commands/reboot.sh

59 is for minutes, second (*) is for hours, third (*) is for days and fourth (*) is for months and fifth (*) is for day in the week (0 = sunday, 6 = saturday)
 
Last edited:
1 comment
Status
Not open for further replies.
Back
Top