crontab syntax

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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值