Re: xServes are dead ;-( / SAN Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



From: Nicolas Ross <rossnick-lists@xxxxxxxxxxx>

> >> >      while true;  do
> >> >            your stuff
> >> >            sleep 60
> >> >       done;
> >>
> >> Sure, but you also need to start the loop and make  sure it doesn't die.
> > Put in /etc/inittab
> >   ms:2345:respawn:/path/to/my/loop_script
> > (where "ms" is  unique).
> > If the loop dies then init will restart it for  you.
> I tought of that, and I will be needing something like this, since I  have 
> some services that need to be restarted in the event of them dying or  being 
> killed.
> But I'm not that much confortable scripting a  modification of the initab to 
> activate / deactivate services on a  server-by-server basis. 

I usually use a lock file and put an entry in cron (like try to relaunch the 
scrip every xxx in case it crashed).
But that means taking care of removing the leftover lock file if the script 
crashed...
Something like:

if [ -f "$LOCK_FILE" ]; then
  PID=`cat "$LOCK_FILE"`
  if [ ! -d "/proc/$PID" ]; then
    rm -f "$LOCK_FILE"
    if [ -f "$STOP_FILE" ]; then rm -f "$STOP_FILE"; fi
    exit 1
  fi
  exit 1
else
  echo $$ > "$LOCK_FILE"
fi  

while [ ! -f "$STOP_FILE" ]; do
  your stuff
  sleep 60
done

rm -f "$STOP_FILE"
rm -f "$LOCK_FILE"

JD


      
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux