You can also give try to daemontools for same though you mileage may vary. *supervise* runs the run script passed to it by *svscan* and monitors the process the script starts so that if it dies, *supervise* restarts it.
http://archive.linuxfromscratch.org/blfs-museum/5.0-pre1/BLFS-BOOK-5.0-PRE1-HTML/basicnet/daemontools.html Good luck Yash Kapil Sethi wrote: >Hi Abhishek, > >I checked the mails after a long time so my suggestions are late. Anyways I >hope it helps. > >===================================================== > >Dear Friends, >I again have a question(looks like i have a lot of questions:) ) >I need a shell script run as a cron to do the following task, >1)Do 'ps -ef' or with other arguments of 'ps ' and see whether a >particular process is executing. Pl. tell me what are the best parameters >of 'ps' to search for a particular process >2) If yes do nothing. >3)If no runs that same process. > 4)Logs all messages to a file >5)Logs all error messages to another file. >I am a novice at shell script. >Pl. help me give some inputs , regarding the best parameters /arguments of >'ps' and whas the method of logging error and normal messages. >Thakns, >-- >Regards, >Abhishek Jain > >========================================================== > >In situations like above, I prefer to let cron do the job of launching as >scheduled at regular intervals. > >I would let the script check if any previous instance is running. If there >is no previous instance then continue else exit gracefuly > >echo "Starting script at `date`" >if [ -f /var/run/script.lck ]; then >echo "Old Lock file found" >PID1=`/var/run/script.lck` >if [ -z "`ps -ef | grep $PID1 | grep -v grep`" ]; then >echo "Looks previous instance exited uncleanly" >echo $$ > /var/run/script.lck >echo "Starting new instance" >else >echo "Previous instance already running" >exit 1 >fi >else >echo $$ > /var/run/script.lck >echo "Starting new instance" >fi > >.... >.... > >and at the end > >rm -f /var/run/script.lck > >cron can redirect the output and errors from the script to separate files. > >Kapil > > > > >_______________________________________________ >ilugd mailinglist -- ilugd@lists.linux-delhi.org >http://frodo.hserus.net/mailman/listinfo/ilugd >Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi >http://www.mail-archive.com/ilugd@lists.linux-delhi.org/ > > > > > > _______________________________________________ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/