0

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.

Kenny Rasschaert
  • 8,925
  • 3
  • 41
  • 58
Grant
  • 1
  • 1
  • 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 07 '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 07 '12 at 15:14

2 Answers2

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.

SimonJGreen
  • 3,195
  • 5
  • 30
  • 55
0
#!/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.

Nils
  • 7,657
  • 3
  • 31
  • 71