Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/156126-restarting-services-when-they-stop/
Share on other sites

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.

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.