Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

DevArticles:
Creation with Cron (and the PHP CLI)
Apr 07, 2003 @ 13:41:35

So, now that you've whipped up this great server-side PHP script to help you out on someting, what do you do with it if you need it to run on a timer? Well, the cron daemon is there for you (well, if you're on a Unix system, that is), and this new DevArticles piece can help you set it all up.

In PHP CLI and Cron, they introduce you to the PHP CLI interface, and how you can create PHP scripts that will run from the command-line. Then, they move on to show you a few examples of how to use the cron daemon on a Unix system, and how to set up your script to run. The cron daemon allows you to specify a time and day for the script to run, so you can tell it things like "run this once every three days" or something as simple as "run this script every 20 minutes". It's a pretty flexible tool for almost all of the Unix-based systems out there.

One downside to the cron setup is that you pretty much have to have shell access (telnet or ssh) for a macine to set it all up. They don't mention it here, but you can't set the up from a web page or anything, unless your hosting provider has something that will allow it. Other than that, it either needs to be just your machine or you need the right access...

tagged:

Link:


Trending Topics: