21
May 2011
Managing Cron Jobs In PHP
Sat, 05/21/2011 - 15:17 — laurenLet’s face it, having the ability to schedule tasks to run in the background is just great! From backing up an SQL database, fetching / sending emails to running clean up tasks, analyzing performance, or even grabbing RSS feeds, cron jobs are fantastic!
Although the syntax of scheduling a new job may seem daunting at first glance, it’s actually relatively simple to understand once you break it down. A cron job will always have five columns each of which represent a chronological ‘operator’ followed by the full path and command to execute:
- * * * * * home/path/to/command/the_command.sh
Each of the chronological columns has a specific relevance to the schedule of the task. They are as follows:
- Minutes represents the minutes of a given hour, 0-59 respectively.
- Hours represents the hours of a given day, 0-23 respectively.
- Days represents the days of a given month, 1-31 respectively.
- Months represents the months of a given year, 1-12 respectively.
- Day of the Week represents the day of the week, Sunday through Saturday, numerically, as 0-6 respectively.
