I implemented this idea, but ran into management issues with the lock file. (The lock file was not deleted properly, it was overwritten, etc.)
Neither of these situations is a problem. The lockfile is only there to be locked. If it is absent, then there is no lock. If it is present a lock should be attempted. The contents of the file (if any) are irrelevant.
You have presented an alternative which is, by comparison, brittle. It relies on shelling out a lot and we know from experience that this can lead to problems.
If managing your own lockfiles with flock is too tricky then why not simply use Script::Singleton as stevieb suggested here? That's a simple, reliable solution.
🦛
In reply to Re: Ensure Only One Instance of Your Script is Running... with 'ps -ef' ?
by hippo
in thread Ensure Only One Instance of Your Script is Running... with 'ps -ef' ?
by redapplesonly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |