in reply to self detecting script
The standard way of doing that is creating a lockfile which contains the pid of the proccess. The proccess will remove the file when exit.
When checking, the new instance will see if the file exists, and if exists, check if the pid stored in the file is still alive (a kill -0 $pid will do it).
If, for some reason, the last proccess didn't remove the lockfile, it will be detected and the next proccess will continue, overriding the lockfile.
|
|---|