Crontab星期日语法 [英] Crontab Day of the Week syntax

查看:164
本文介绍了Crontab星期日语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在crontab中,星期字段从 0 - 6 1 -7 p>

我看到有关这方面的冲突信息。维基百科 0-6 和其他我看到的网站是 1-7



还有什么是暗示或者使用 0 7 不正确?即cron是否仍在运行?

解决方案

0 7 都代表星期天,你可以使用你想要的,所以写0-6或1-7有相同的结果(见下面的代码中的注释一个更好的例子)。



1 6 的数字被固定为星期一,...,星期六



 ┌────────分钟(0  -  59)
│┌─── ─────小时(0 - 23)
││┌─────月((1 - 31)
│││┌───月(1 - 12)
││││┌──星期几(0-6 =>星期日 - 星期六或
│││││1 - 7 =>星期一 - 星期日)
↓ ↓↓↓↓
* * * * *要执行的命令

by @Henrik,可以使用缩写的天数替换数字,例如 MON THU 等。



最后,如果您要逐日指定,可以使用逗号分隔日期,例如 SUN,MON,THU

更多关于维基百科


In crontab does the Day of the Week field run from 0 - 6 or 1 -7?

I am seeing conflicting information on this. wikipedia states 0-6 and other sites I have seen are 1-7.

Also what would be the implication or either using 0 or 7 incorrectly? i.e. would the cron still run?

解决方案

0 and 7 both stand for Sunday, you can use the one you want, so writing 0-6 or 1-7 has the same result (see comments in code below for a better example).

The numbers from 1 to 6 are fixed to Monday, ..., Saturday.

Graphically:

 ┌────────── minute (0 - 59)
 │ ┌──────── hour (0 - 23)
 │ │ ┌────── day of month (1 - 31)
 │ │ │ ┌──── month (1 - 12)
 │ │ │ │ ┌── day of week (0 - 6 => Sunday - Saturday, or
 │ │ │ │ │                1 - 7 => Monday - Sunday)
 ↓ ↓ ↓ ↓ ↓
 * * * * * command to be executed

Also, as suggested by @Henrik, it is possible to replace numbers by shortened name of days, such as MON, THU, etc.

Finally, if you want to specify day by day, you can separate days with commas, for example SUN,MON,THU will exectute the command only on sundays, mondays on thursdays.

More informations on Wikipedia.

这篇关于Crontab星期日语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆