Quote:
Originally Posted by Raynon
I am refering to this particular exmaple that you have provided me.
Code:
#!/bin/csh
set numprocs=`ps -ef | grep -v grep | grep $scriptname | wc -l | awk '{ print $1 }'`
if ($numprocs == 1) then
# carry on
else
echo "Another instance is already running, exiting..."
exit 0
endif
What is the significance of the numprocs?
If it equals to 1 , why does it show that the script is not running anymore?
|
Because one copy is running, the one that's currently executing. It's looking for another version of itself (ie 2 or more) in case there are other copies still running.
Quote:
Originally Posted by Raynon
I tried a simple csh script below and it doesn;t really work.
When it is sleeping, the name of the script which is "myscriptname" is not reflected during " ps -ef ", it only shows " usr 28951 28941 0 15:00:39 pts/7 0:00 sleep 100 ".
|
Works for me, when I run a csh script with a sleep in it, I see the sleep, _and_ the main script running.