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.

  • 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

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.

| improve this answer | |
typeset -i RC
rcgrpwise status >dev/null 2>&1
let RC=$?
if [ $RC -ne 0 ]
     rcpgrwise restart
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.

| 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.