in reply to Determine if script is already running
Furthermore, if the program doesn't get the chance to run the END block (kill -9, exec), it might happen that the next time an instance is run, it finds the lockfile, and it just happens there's an unrelated process running with the same PID as mentioned in the PID file.
I'd say, open the file for read/write/create, and then try to gain an exclusive lock (non-blocking). If you get the lock, you're the only instance running. Keep the lock until the program terminates. Regardless how the process terminates, the kernel will release the lock (but make sure you pick a local file, not one mounted by NFS).
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Determine if script is already running
by Nitrox (Chaplain) on Mar 03, 2003 at 01:52 UTC |