简体   繁体   English

要设置的cron

[英]cron to be setup

I have an already setted up cron job. 我已经完成了一项cron工作。 Now i have a file whose cron i have to setup such that my file should run at 9:00 am,11:00am,1:00pm,5:00pm and 7:00pm 现在我有一个文件,其cron我必须设置,以便我的文件应该在上午9点,上午11点,下午1点,下午5点和下午7点运行

Idont have much idea about cron So can anyone please help me in setting up this cron for my file at the aboove given timings !! 我对cron有很多想法所以任何人都可以帮助我在上一个给定的时间为我的文件设置这个cron !!

The format for the CRON Jobs is: CRON Jobs的格式是:

minute hour dom month dow user cmd

minute This controls what minute of the hour the command will run on, and is between '0' and '59' minute它控制命令运行的小时,在'0'和'59'之间


hour This controls what hour the command will run on, and is specified in the 24 hour clock, values must be between 0 and 23 (0 is midnight) 小时它控制命令运行的小时,并在24小时制中指定,值必须介于0和23之间(0为午夜)


dom This is the Day of Month, that you want the command run on, eg to run a command on the 19th of each month, the dom would be 19. dom这是一个月中的日子,你希望命令运行,例如在每个月的19日运行一个命令,dom将是19。


month This is the month a specified command will run on, it may be specified numerically (0-12), or as the name of the month (eg May) month这是指定命令运行的月份,可以用数字(0-12)指定,也可以作为月份的名称(例如May)


dow This is the Day of Week that you want a command to be run on, it can also be numeric (0-7) or as the name of the day (eg sun). dow这是您希望运行命令的星期 ,它也可以是数字(0-7)或当天的名称(例如太阳)。


user This is the user who runs the command. user这是运行该命令的用户。


cmd This is the command that you want run. cmd这是您要运行的命令。 This field may contain multiple words or spaces. 该字段可能包含多个单词或空格。


If you don't wish to specify a value for a field, just place a * in the field. 如果您不想为字段指定值,只需在字段中放置*即可。


Here is an example of how a crontab is setup. 以下是如何设置crontab的示例。

01 * * * * root echo "This command is run at one min past every hour"
17 8 * * * root echo "This command is run daily at 8:17 am"
17 20 * * * root echo "This command is run daily at 8:17 pm"
00 4 * * 0 root echo "This command is run at 4 am every Sunday"
* 4 * * Sun root echo "So is this"
42 4 1 * * root echo "This command is run 4:42 am every 1st of the month"
01 * 19 07 * root echo "This command is run hourly on the 19th of July"

Each of the positions means a specific thing: 每个职位都意味着一个特定的事情:

  1. Minute [0,59] 分钟[0,59]
  2. Hour [0,23] 小时[0,23]
  3. Day of the month [1,31] 每月的某一天[1,31]
  4. Month of the year [1,12] 一年中的某个月[1,12]
  5. Day of the week ([0,6] with 0=Sunday) 星期几([0,6],0 =星期天)

For example: 例如:

0 9,11,13,17,19 * * * /bin/whatever >> /some/log/if/you/want/it.log

In English: 用英语:

Run /bin/whatever on the 0th minute of the 9th, 11th, 13th, 17th, and 19th hour of every day, of every month, each day of the week. 在每个月,每个月,每周的每一天的第9,11,13,17和19小时的第0分钟运行/ bin /。

0 9,11,13,17,19 * * * something

man 5 crontab

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM