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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Matt <datahead4@xxxxxxxxx> :
> Perhaps "svscan" and its associated "daemontools" programs could be
> used to monitor the script instead of relying on cron.

Just a note: The above suggestion would assume you control the box, and
that you're running on a *nix system (i.e., you've got root on a linux,
bsd, solaris, AIX, etc. server).

> On 8/2/05, André Medeiros <andre.caum@xxxxxxxxx> wrote:
> > On Tue, 2005-08-02 at 15:09 +0100, Stut wrote:
> > > André Medeiros wrote:
> > > > 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 :)
> > >
> > > Personally I'd extend that slightly to have the process touch the PID
> > > file every so often and to check that it's been touched recently when it
> > > starts up. Alternatively use the ps shell command to check that a
> > > process with that PID is still running, but that tends to be less reliable.
> > >
> > > If the process does decide to continue in spite of the PID file existing
> > > it should issue a a shell kill command to kill that PID in case it's
> > > hung or a zombie.
> > >
> > > -Stut
> > 
> > Excelent point!

-- 
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux