Portal Home > Knowledgebase > Articles Database > Script to restart Apache on big memory consumption
Script to restart Apache on big memory consumption
Posted by WebHostDog, 03-02-2012, 01:39 PM |
I need a good solution to watch the Apache overall memory usage and restart it in case of big loadavg and/or memory usage. Anybody is using something proven and working ?
|
Posted by rustelekom, 03-02-2012, 02:02 PM |
Hi,
Monit could be good solution.
|
Posted by hostfeat, 03-02-2012, 02:06 PM |
I think you shouldn't use like this scripts! when the Apache memory usage is high you have to investigate the issue before restarts it(this is my idea and what I usually do).
|
Posted by WebHostDog, 03-03-2012, 06:45 AM |
Yes I am using monit but for some reason it cannot restart Apache. Before years I was using it and was working fine. It is a cPanel server though. Do not know what might be the workaround for this.
|
Posted by jibinthomas007, 03-08-2012, 05:15 AM |
You can use the following script to restart apache when load hikes more than 5
vi load.sh
enter the following codes and save
n=uptime | awk {'print $8'} | cut -d, -f1
if [ n -gt 5 ];then
/etc/init.d/httpd restart
fi;
chmod 755 load.sh
set as a cron in the server to execute every 5 minute.
|
Posted by SiteServing, 03-08-2012, 06:23 PM |
Monit has problems reading /proc when there is grsecurity kernel in place.
|
Add to Favourites Print this Article
Also Read