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.

We are running OES2/SuSE. The problem is with our groupwise webaccess. From time to time it stops and we just have to restart the process. The commands are:

rcgrpwise status
rcgrpwise start

How would I create a script that would check the status and if it comes back stopped, then it would run the rcgrpwise start command.

share|improve this question
1  
Is it actually stopped, or has it died (was killed)? There's a huge difference in UNIX world between those two states... –  Hubert Kario Jan 7 '12 at 15:09
2  
One more thing: checking why it crashed will be much more productive. Check logs. It also may be a sign of some other problem (faulty RAM). –  Hubert Kario Jan 7 '12 at 15:14

2 Answers 2

If it's a really simple process to start I would probably add it to inittab with a respawn entry. Otherwise look at using something like monit to check and automatically restart processes.

share|improve this answer
#!/bin/sh
typeset -i RC
rcgrpwise status >dev/null 2>&1
let RC=$?
if [ $RC -ne 0 ]
   then
     rcpgrwise restart
fi
sleep 3
rcgrpwise status >/dev/null 2>&1
exit $?

Save this as script and call it from cron.

or shorter:

rcgrpwise status >/dev/null 2>&1 || rcgrpwise restart

But as others have stated - you should research why this is stalling.

share|improve this answer

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.