in reply to Re: self detecting script
in thread self detecting script

Probably not ideal, but this is almost a not too bad method when you know that separate instances of the same program will always start not less than a minute apart. There should be no race conditions. But if for some reason the previous instance never unlinks the file, no subsequent instance will run, which may or may not be what you want. Or if you manually start up the process at the same time cron kicks it off, you may run into a race condition. It may be best to open the file unconditionally and then use lock to get an exclusive lock on the file. Or use one of the previously mentioned modules to do that for you.

I'll also mention that we do that sort of thing alot in our shell scripts, but it's the only solution since we can't call lock from the shell (also perl is not installed on many of our customer's systems). Unfortunately, we also use this method in shell scripts outside of cron where race conditions are possible, and some sort of file lock would be better.