Re: Checking if a script is already running ...

Re: Checking if a script is already running ...

 

  

Semaphore files are your friend. Here's a snippet to add to the
beginning of your script...

FN=/tmp/flag.tmp
if [ -f $FN ]; then
touch $FN
#Run your Script here
rm $FN
else
echo "Script $program is already active
fi

The program starts, if it's not running (no semaphore file) then it
creates the semaphore file and runs your script, other wise it exits.

At 13:42 7/2/2006, benbart wrote:
>Hi all,
>
>Does anyone have a smarter script to check whether a certain script is already
>running and if so exit from the script instead of running another instance of
>the script?
>
>At the moment, am checking it using ps -ef | grep [scriptname], but found out
>that this is not a reliable test as someone could be more'ing or cat'ting a
>file and I am mistakenly taking it as the script running ...
>
>Any advise or tips will be very much appreciated ... thanks in advance ...
>
>
>
>
>
>--------
>website: http://www.LazyDBA.com
>Please don't reply to RTFM questions
>Oracle documentation is here: http://tahiti.oracle.com
>To unsubscribe: see http://www.lazydba.com/unsubscribe.html
>To subscribe: see http://www.lazydba.com
>By using this list you agree to these terms:http://www.lazydba.com/legal.html


Oracle LazyDBA home page