wiggst3r Posted April 29, 2009 Share Posted April 29, 2009 Hi I'm running a Ubuntu webserver, which has several services running. As the server is quite well used and has several sites hosted on it, I was wondering If anyone could help me with some code/script that will restart any service that goes down or stops. I'm looking to restart the following, If they ever stop: Apache Mongrel MySQL Cron Postfix I'm sure there could be an init script that could be run and will restart any of these services If they ever stop. Thanks Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted April 29, 2009 Share Posted April 29, 2009 You could write a script that checks if it's running, and if not then start it. Then add a cron entry to run it at a certain interval. So, on my Gentoo VPS, if I might do something like this: degeberg ~ # /etc/init.d/apache2 status * status: started So that tells me that Apache is running. If it hadn't returned that then I could execute /etc/init.d/apache2 start to start Apache. Do that for all of your services, make a script out of it and use cron to routinely run it. This can of course not be used to check if your cron daemon is down, but I don't think you can guard against that without having an external server check that. Quote Link to comment Share on other sites More sharing options...
steviewdr Posted April 30, 2009 Share Posted April 30, 2009 See monit. http://www.debianadmin.com/monitoring-debian-servers-using-monit.html Its probably on apt for ubuntu also. The problem I foresee is, that if your server OOM's (runs out of memory) then the monit service itself will have its memory squeezed and could stop as wekk. -steve Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted May 1, 2009 Share Posted May 1, 2009 Yeah that was essentially the problem in my post as well. If the monitor fails, who monitors the monitor? Quote Link to comment Share on other sites More sharing options...
steviewdr Posted May 5, 2009 Share Posted May 5, 2009 Well I use Xen, a lot. So much so, I have all my services broken out amongst 3 vm's. Dom0 (running solid and very capable on 128mb of ram) can then monitor to see if a domU has OOM'd etc. destroy the vm and create a new vm instance. Of course there is a lot of setting up in that. -steve Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.