crontab syntax
转自:http://en.wikipedia.org/wiki/Cron
The crontab files are stored where the lists of jobs and other instructions to the cron daemon are kept. Users can have their own individual crontab files and often there is a systemwide crontab file (usually in /etc or a subdirectory of /etc) which only system administrators can edit.
Each line of a crontab file represents a job and follows a particular format as a series of fields, separated by spaces and/or tabs. Each field can have a single value or a series of values.
Operators
There are several ways of specifying multiple date/time values in a field:
The comma (',') operator specifies a list of values, for example: "1,3,4,7,8" (space inside the list must not be used)
The dash ('-') operator specifies a range of values, for example: "1-6", which is equivalent to "1,2,3,4,5,6"
The asterisk ('*') operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to 'every hour' (subject to matching other specified fields).
There is also an operator which some extended versions of cron support, the slash ('/') operator (called "step"), which can be used to skip a given number of values. For example, "*/3" in the hour time field is equivalent to "0,3,6,9,12,15,18,21".
So "*" specifies 'every hour' but the "*/3" means only those hours divisible by 3. The meaning of '/' specifier, however, means "when the modulo is zero" rather than "every". For example, "*/61" in the minute will in fact be executed hourly, not every 61 minutes.
Example: the following will clear the Apache error log at one minute past midnight ( 00:01 of every day of the month, of every day of the week ).
1 0 * * * echo -n "" > /www/apache/logs/error_log
Slash example: the following will run the script. /home/user/test.pl every 5 minutes.
*/5 * * * * /home/user/test.pl
.---------------- minute (0 - 59)
| .------------- hour (0 - 23)
| | .---------- day of month (1 - 31)
| | | .------- month (1 - 12) OR jan,feb,mar,apr ...
| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * command to be executed
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7419833/viewspace-624983/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7419833/viewspace-624983/