script which restarts apache automatically

mukamo

New member
Joined
Nov 22, 2005
Messages
4
hi all

is there a script that runs every minute or so which checks the server load and when it reaches a certain number say 4.0, it executes

service httpd restart


:)

thanks in advance
 
There would be a reason if your server reached a load like that. Just restarting the webserver is not gonna change anything. You are just killing the established connections. Once they all reconnect the load will be the same.
 
but the server load just shoots up only once in awhile and an apache restart always fixes it
 
#!/bin/sh

ld=`uptime | awk -F, '{print $5}' | awk -F. '{print $1}'`;
limit=5;

if [ $ld -gt $limit ]; then
`service httpd restart`;
fi


Then put it in crontab
*/5 * * * * root path_to_script
 
Back
Top