XP is just a number | |
PerlMonks |
Re: Preventing multiple instancesby stevieb (Canon) |
on Dec 16, 2020 at 22:01 UTC ( [id://11125307]=note: print w/replies, xml ) | Need Help?? |
In very simple cases, such as this one, I use shared memory, or create a memory-backed directory:
Add the following line to the bottom of your /etc/fstab file (you'll need sudo to do this):
You've now created a directory, /var/memdir which only exists in memory (meaning it'll be wiped after reboot). It's only one megabyte, increase size as necessary. Put your lock file in that directory. In simple cases, like the one you've got, I don't even write anything to the file, I just simply created it, then use exit if -e '/var/memdir/prog_name.lck';. A more complete example:
Output:
In Section
Seekers of Perl Wisdom
|
|