> -----Original Message----- > From: Elizabeth Cortell [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 03, 2007 4:48 PM > To: beginners@perl.org > Subject: Re: Limiting a program to a single running instance > > Checking for instances by grepping the output of ps tends to > also catch instances of > > vi myscript.pl > > So that innocently editing the file on that box keeps it from > running! Not what you have in mind, I think. > > I suggest (untested, but we do something like this in the office): > Upon startup, check for the existence of a lockfile with > agreed-upon name in some tmp directory. If it exists, exit > immediately; otherwise create the file. Remove the file at > end of execution or upon death of script (in the END block). > > I haven't thought out all the ways that could go wrong. > Comments welcome. > > > Cheers, > > Liz
If the process crashes, it won't always remove the file. Put the Process ID in the file, then the next run can check to see if that process is still alive and running the same application. If not, remove the file and continue. Bob McConnell -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/