Automated Script

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Guys, I need to make an automated script that runs every x seconds
without using a CRON job.

I heard there was a way doing it only in PHP. If you know any function
that can be used please inform me about it.

Re: Automated Script

not possible using php only.

three possible ways around:

1. use some web based cron (can't remember an url at the moment, sorry)

2. if you have a local pc that's online 24h, have a little program
there calling the automated script every x seconds

3. use the most frequented page of your website to call the automated
script (using a blind image, for instance). you'd have to include a
timer in the automated script than.


Re: Automated Script

chotiwallah wrote:
Quoted text here. Click to load it

You could use an infinite loop and stick the code to be executed inside  
with a sleep at the end.

$x = 5;
while(1) {
  echo "Hello world";

Or if you want to re-execute the code a set number of times use:

$x = 5;
$y = 10;
for ($c = 0; $c < $y; $c++) {
  echo "Hello world";

Andrew @ Rockface
np: Sylvie - Smoke and Mirrors [stopped]

Re: Automated Script

On Tue, 4 Oct 2005 07:50:59 +0000 (UTC), Andrew @ Rockface wrote:

Quoted text here. Click to load it

I've been digging around looking for info on precisely this topic.

Not sure whether your code will work (infinitely). It will simply hit
the maximum page execution time set by php.ini on the server - then
throw an ugly error.

You could extend that time with ini_set() - but I'm not sure whether
there's a memory or performance hit on a server processing an infinite
loop. It would also dependon what is actually happeniong iside the


Re: Automated Script

Adam wrote:
Quoted text here. Click to load it


I generally run php scripts using wget from a crontab job. In fact I do  
that every hour to run remote tests on around 60 sites and have found  
it's perfect for the job.

Andrew @ Rockface
np: (Winamp is not active ;-)

Re: Automated Script

chotiwallah wrote:
Quoted text here. Click to load it

   FWIW, it's


Quoted text here. Click to load it

   FWIW, you don't have to go for webbug, it's enough that you put your
own cron_handler() function in frequently accessed PHP file. May also
use auto_prepend_file feature
< , (but it's a
discouraged approach). But, as you said, it's like reinventing the

   Possibly, the pure PHP solution is to use sleep() function and set
the maximum execution time to 0 (no limit) and to use it in command
line (so, that it doesn't use webserver resources).

  <?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com    Blog:

Site Timeline