If you create a lock file (perhaps in /var/lock), with the program's
file name, ending in .lck, you can check for that at the beginning of the
perl script and exit immediately if that file exists.  At the end of the
perl script delete the file.

  You can still have a race condition if two people click on the button at
the same instance, but it is highly unlikely, and can be disregarded for
your purposes.

bug


On Tue, 28 Mar 2000, Michael D. Kirkpatrick wrote:

> Is there a way to mark a perl script to be ran as a single process only?
> 
> The problem:
> I have a perl script that takes 3-5 seconds to run (Very large databases)
> If I mess up and double click on the submit button, a second process is
> spawned off.  This completely slows down the first process and takes twice
> as long to process.  As for a test, I clicked the submit button 20 times
> and it spawned off 20 processes and totally slowed down the server for a
> long while.
> 
> I want the server to reject the script from running more then 1 process.
> Is this a perl thing where I have to encode in the script to check for
> other copies being ran?  Or is there an access right that can be set where
> it only allows 1 copy to be ran?
> 
> This is not a public script.  There are 5 people that access this script on
> a regular basis.
> 
> Thanks in advance.
> 

Reply via email to