Page 1 of 1

How to make Apache autoexecute a PHP file?

Posted: Wed May 25, 2005 10:06 pm
by juanirecla
Hello everyone!

I'm looking for a php code that set apache server to autoexecute a file (for example: example.php) every 12 hours.

My idea is to make that file maintained update a central mysql db every an elapsed time.

The example.php file don't will return HTML code, it will have only php code that will be execute on the server to check a db information of another's hosts.

Thanks for all!
Juani.

Posted: Wed May 25, 2005 10:22 pm
by Burrito
use cron if it's on a *nix system or scheduled tasks on Windows and run php.exe from the cli you should.

Posted: Thu May 26, 2005 6:23 am
by Bennettman
An alternative option if you don't want to use cron (if it's related to something like a forum or gets visited regularly, and you don't need it to run at exactly the right time), is to have a value in text file or DB with the time it's next scheduled to run, then whenever someone visits have the script check that value against the current time. If it's in the past, run the script (exec typically) and increment the next-run time.

Posted: Thu May 26, 2005 9:42 am
by juanirecla
Thankss!! Yes, but I don't want to delay the first consult wile the db is updated. . .

Is dificult to configure the cron? I have to say it to de hostmaster to do it? Because I imagine I don't have enought permisions to access to that part of the server. .

There's any way to configure it using php functions?

Thanks again!!
Juani.