Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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. –  ultrasawblade Aug 23 '12 at 20:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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