Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to monitor hanging processes on the output of ps -ef | grem GMC...

What's the best way to do this without running this command manually and being stuck in front of a command line all day? I'd like to our dev team to get an email whenever one of these processes hangs so we can investigate, or better yet, auto-killing dying processes.

SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 1
LSB_VERSION="core-2.0-noarch:core-3.0-noarch:core-2.0-x86_64:core-3.0-x86_64"
Novell Open Enterprise Server 2 (x86_64)
VERSION = 2
BUILD = FCS
share|improve this question
    
if you know what output you're looking for from the ps command, it should be as simple as writing a script and putting it in a cron –  sreimer Apr 13 '11 at 19:00
    
What happens when the process hangs ? –  Iain Apr 13 '11 at 19:28
add comment

1 Answer

A simple script like the one following does the magic:

#!/bin/bash

PROCESS=`ps auxw | grep GMC | grep -v grep`

if [ -z $PROCESS ]; then
  echo "Process GMC not running" | mail -s "Alert" yourmail@address.com
fi

Then run this every 5 minutes from your crontab.

You might also want to check tools like daemontools or monit. Both these tools are open source utilities that check processes and restart them if they're not running.

Hope this helps!

share|improve this answer
    
Will this tell me when it's stalled? –  Webnet Apr 13 '11 at 20:25
    
you can tune the script to do that as well. –  Marco Ramos Apr 13 '11 at 21:05
    
How can I do that? –  Webnet Apr 14 '11 at 12:36
    
Does the process write some kind of output/log? –  Marco Ramos Apr 14 '11 at 18:20
    
What happens the the process hangs? –  Marco Ramos Apr 14 '11 at 18:21
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.