Web Design Articles and News
How to setup a cron job
If you omit the file argument, crontab takes input from the standard input.
Input consists of six fields, separated by blanks. The first five give a date and time in the following form:
A minute, expressed as a number from 0 through 59.
An hour, expressed as a number from 0 through 23.
A day of the month, expressed as a number from 1 through 31.
A month of the year, expressed as a number from 1 through 12.
A day of the week, expressed as a number from 0 through 6 (with 0 standing for Sunday).
Any of these fields may contain an asterisk * standing for all possible values. For example, if you have an * as the day of the month, the job runs every day of the month. A field can also contain a set of numbers separated by commas, or a range of numbers, with the first number followed by a minus sign - followed by the second number. If you give specific days for both day of the month and day of the week, the two are ORed together.
Here are some examples.
0 0 * * * -- midnight every day
0 0 * * 1-5 -- midnight every weekday
0 0 1,15 * * -- midnight on 1st and 15th
of month
0 0 1 * 5 -- midnight on 1st of month
and every FridayThe sixth field of a crontab entry is a string that your shell executes at the specified time.
If the string in your crontab entry contains percent characters %, they are interpreted as newline characters, splitting your string in several logical lines. You can include an actual % character in this string by escaping it with a backslash (\). The first logical line (up to the first unescaped %) is interpreted as the command you want to execute; subsequent logical lines are used as standard input to the command. If any real (not logical) line in the file is blank or begins with #, the shell ignores the line (treats it as a comment).

