Cron - Paint by Colors
Lets explore and begin to understand the crontab command and then we'll be able to apply it using the method that we have available (via control panel or telnet). Look at the following basic crontab:
A typical crontab command, explained below.
I'll color code each "section" to allow me to visually explain the different parts of this crontab.

A color coded crontab command.
Here's an explanation of the above cron command:
|
Minute of the hour Set to a number between 0 – 59 for the corresponding minute of the hour or * for every minute |
|
Hour of the day Set to a number between 0-23 for the corresponding hour of the day or * for every hour |
|
Day of the month Set to number between 1-31 for the corresponding day of the month or * for every day |
|
Month of the year Set to a number between 1-12 for the corresponding month of the year or * for every month You can use the name of the month of the year as well eg. march (not case sensitive) |
|
Day of the week Set to a number between 0-7 for the corresponding day of the week (0 or 7 is Sunday) You can use the name of the day of the week as well. Eg. Tuesday (not case sensitive) |
|
Beginning of the command line Here you specify the path to PHP or Perl and any flags you might need. |
|
The path to your script Specify the path to your script that you want to run. |
What is the asterisk and what does it do?
The Asterisk specifies that the script should be run on every occurrence of a time change. For example, if you want to set a cron to run every hour, then you would place an asterisk in the 'hour' column. Eg. 0 * 1 1 1 Setting a range within a column.
You can set a range of values in the cron command so that it will run within that range. Eg. 2-5 will run 2, 3, 4 and 5 of the column you set it in. In the day of the month column, for example, this 2-5 setting will run on the 2nd, 3rd, 4th and 5th of the month and will look like this. 0 * 2-5 * * Setting the frequency within each column.
If you wanted to run a cronjob every 5 minutes, you would be able to use */5 in the minutes column. If it was every 5 hours, then */5 could be placed in the hours column. Many would confuse this */5 as a fraction, but it is actually setting the frequency that the cron takes place in that column. It means 'every five' rather than a fifth of it.
For information on setting up your cron in Plesk, Cpanel or via SSH please have a look at these other knowledge base entries.
