RE: [PHP] Is CRON'd PHP script already running?

From: Date: Thu, 20 Sep 2001 19:07:09 +0000
Subject: RE: [PHP] Is CRON'd PHP script already running?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-68047@lists.php.net to get a copy of this message
On 20-Sep-2001 Simon Kimber wrote: > Hi All, > > I have a PHP script that i want to run every few minutes (via cron) but I > only want it to run if it isn't already running. > > Is there something in cron itself to solve this or is there a way within PHP > to detect that another instance of the current script is running and if so > exit the new instance before it does anything... > > eg. I could have a function to use like so: > > if (already_running($SCRIPT_NAME)) { > exit(); > } > > Thanks in advance! > in a shell wrapper: #!/bin/sh mkdir $HOME/LCK.script >> /dev/null 2>&1 || exit 1; ... do_yer_thang rmdir $HOME/LCK.script Regards, -- Don Read dread@texas.net -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it.

« previous php.general (#68047) next »