Re: Run script every 30 seconds

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

 



On Mon, 30 Oct 2006 21:26:29 +0300, Ahmad Al-Twaijiry wrote:

The "right" way to do this, as others have mentioned, is with a
daemon. Having said that...

>is it possible to link the script to my php interface (the one that
>the users is using it) and if the php interface page will run the
>script (IN background) if it didn't run for the last 30 seconds ? I
>see  this is very hard and almost impossible , what do you think ?

http://www.webcron.org/

However, an admin on a shared host may (quite rightly) kick you for
wasting shared resources.

A script that has to be run every 30 seconds sounds like it's covering
for a bad design decision to me. Can you tell us more about what
you're trying to accomplish? We might be able to find a more elegant
solution.

>PS: also I need to make sure no more than 1 process of the script is running :)

Locking. At its simplest, have your script create a dummy file when it
first runs, and delete it when it exits. If the file already exists,
then you know that a copy of your script is already running, so you
exit. (Include a timeout in case the script dies halfway through - if
the file is more than 5 minutes old, run anyway).

-- 
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