Re: Run script every 30 seconds

From: Date: Mon, 30 Oct 2006 19:59:07 +0000
Subject: Re: Run script every 30 seconds
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-243909@lists.php.net to get a copy of this message
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).

« previous php.general (#243909) next »