in reply to Abort if instance already running?
Well, the traditional way is to look for "/var/run/".basename($0)."pid". If it exists, read its contents (a PID). Lookup that PID int the process table (or test -d "/proc/$pid" and check /proc/$pid/cmdline to be sure), if positive, exit gracefully. Else overwrite "/var/run/".basename($0)."pid" with your own $$.
There's a solution with flock(2) too... merlyn has written a column about that, IIRC (update: what Corion says :-) . Ah, wait... the best way? whatever works best on your system ;)
|
|---|