One day soon, the task of running basic scripts on your server will be outsourced to the cheap labor supply in Elbonia. Masses of Elbonians will consider themselves wealthy with their half-cup of mud per day wages to simply run timed commands on computers around the world.
Until then, we can just use Cron.
Cron is a system timer on *nix systems for running commands at appointed times. These events and times are stored as Crontabs.
For a holiday analogy, consider the humble timer you may hook to your christmas lights to turn them on automatically in the evening and then off while you are having dreams about sugar plums that even Freud would have trouble explaining. You take this little timer and plug it in. You set the current time on it and then take the little plastic tabs and insert them where you want the lights to turn on and then off.
Windows has something like this called the task scheduler. This is the type of program that helps you keep your antivirus up to date or your disk defragmented.
I will get into the details of using cron sometime in the future (I am still writing up some info on it), but I just posted some instructions on how to get cron to run a php (or PERL, or any other web based scripting language) file.
Cron only allows command line tasks, so the trick it to either write your script to be able to be run from the command line, or just write it to be accessible from the web site like any other file and then tell the command line to get it from there.
Hey, the file you run doesn’t even have to be on your server. You could do this for your friends and become the most popular geek on the block.
Enjoy: Calling a PHP File from Cron



0 Responses to “Call PHP using Cron”