0

I want to monitor a couple of services in linux. In case they go down I want to restart them.

I'm writing a crontab which will get the name of the services using jps command every 60 seconds, and if they're not present in the resultset, issue a restart command specific to each of these services.

I want these services to be always available so in case they go down I'm able to get them up and running again.

I'm worried that in case any of these services hang up how will I know. Is there a way to know about hung services and kill them?

Is there a clean way of implementing auto restart of services which will handle both "services that go down" and "services that hang up".

  • 5
    All of the answers depend on what services you're talking about. Can you query them and see if they respond, do they write log entries, etc. etc. Be aware you may be re-inventing the wheel, have a look at the existing monitoring solutions (such as Nagios). So, you may want to provide more concrete information on the specific services you're talking about. – EightBitTony Jun 20 '13 at 22:45
  • What distro and init system? – jordanm Jun 21 '13 at 0:19
0

A lot of software has been written already to solve this kind of problem; f.e. Monit and supervisord. Don't reinvent the wheel.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.