How to make Apache autoexecute a PHP file?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
juanirecla
Forum Newbie
Posts: 8
Joined: Wed May 25, 2005 9:47 pm

How to make Apache autoexecute a PHP file?

Post 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.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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.
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Post 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.
juanirecla
Forum Newbie
Posts: 8
Joined: Wed May 25, 2005 9:47 pm

Post 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.
Post Reply