Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bash script that runs a process -

it runs from an xsession /usr/share/xsessions/$user.desktop

I want to monitor the status of that process using monit.

Is it possible to create a pid and monitor that pid

If it finds the process has frozen or is unrespoinsive then run my script again to start the process again?

share|improve this question
up vote 1 down vote accepted

You can monitor anything you want using monit - it's very flexible. Depending upon what and how you want to monitor it, you'll have to dig into how the configuration works.

You first have to define what it means for your process to be "unresponsive."

The "SERVICE TESTS" section of Monit man page lists all the things that Monit can do to determine if something is running or not.

If you are particularly brave you could replace init with monit - but you probably have a lot of work ahead of you and the payoff is likely not going to be worth it.

You may also want to look into upstart as it's a "drop-in" (from what I hear) replacement for init that's designed to do things like this (but I don't know very much about it)

share|improve this answer
Thats great but - how would I monitor a process that wasnt started using init? would upstart subsitute that? – Rob Aug 23 '12 at 20:05
Ok I think I can alter my script to make a pid file then have one script to kill the program and delete the pid - this will form the basis for the monit service – Rob Aug 23 '12 at 20:14
You don't run upstart and init at once, I believe. upstart is an init replacement with enhancements. – LawrenceC Aug 23 '12 at 20:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .