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

Re: how to run scripts uniquely



On Thu, Nov 22, 2007 at 06:26:40PM +0000, cs wrote:
> I thought I'd worked out how to ensure only 1 instance of a shell script
> was running (using grep and wc) but I now see that sometimes the script
> name appears twice in the list of processes - any ideas?

Whenever I've needed to do that, I follow the 'standard' method with a
file in /var/lock.  Create a file with your script name and put its PID
in it.  Your script can then test for the existance of this file, read
it, and verify the existance of the PID (remove the file if the PID is
dead) and create its own lock file, removing it on successfull
completion.


Doug.



Reply to: