Re: How to determine if a script instance is already running?

From: Date: Tue, 02 Aug 2005 14:59:30 +0000
Subject: Re: How to determine if a script instance is already running?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-219822@lists.php.net to get a copy of this message
On Tue, 2005-08-02 at 09:49 -0400, Jim Moseby wrote: > I have a command line script that needs to run continuously, and so I plan > to have cron execute it every so often. I want to have the script first > check to see if another instance is already running and, if so, die(). > > Now, I know I can exec the process list and parse through the output, but is > there and easier, faster, cooler, sexier, better way? :o) > > JM > Do like some services do: 1) Check if script.pid exists 2) If it doesn't 2.1) Write the process's PID onto the file (http://pt.php.net/manual/en/function.getmypid.php) 3) If it does 3.1) Die gracefully :)

« previous php.general (#219822) next »