Hi all Thanks Oscar. I didnt know about the pidof command. With your example of using the return value I now have my script working.
I tested it out by killing apache with -9 and leaving a PID file around. The test for the PID file like [ -f $APACHEPID ] would indicate that apache was still running. Using pidof gives a list of pids if its running and nothing if its not. It's exit status is "0 At least one program was found with the requested name. 1 No program was found with the requested name." Hence its perfect for my script. Thanks for the other suggestions too. On Tue Jan 10, O Plameras wrote: > Use 'pidof' (PID of command). > > A small script to demonstrate how to check if /usr/sbin/apache-perl is > running. > > #!/bin/sh > RET=0 > pidof /usr/sbin/apache-perl >/dev/null 2>/dev/null > RET=$? > [ $RET -eq 0 ] && echo Running && exit 0 > echo Not Running > exit 1 > > To distinguished among processes (same name) save output > from 'pidof' command (instead of dropping off to /dev/null) and > process. This is going to be a bit involved. > > A simpler way is to copy apache-perl into different directories > and use, > > pidof /dir1/apache-perl > pidof /dir2/apache-perl > etc. > by using the method in the script above. -- -- Mike Lake Caver, Linux enthusiast and interested in anything technical. -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
