我正在试图弄清楚如何在每个星期天运行crontab作业。我认为以下应该可以工作,但我不确定我是否理解正确。以下内容正确吗?

5 8 * * 6

当前回答

10 * * *太阳

Position 1 for minutes, allowed values are 1-60
position 2 for hours, allowed values are 1-24
position 3 for day of month ,allowed values are 1-31
position 4 for month ,allowed values are 1-12 
position 5 for day of week ,allowed values are 1-7 or and the day starts at Monday. 

其他回答

在指定cron值时,您需要确保您的值在该范围内。例如,一些cron使用0-7范围表示星期几,其中0和7表示星期日。我们没有(请看下面)。

Seconds: 0-59
Minutes: 0-59
Hours: 0-23
Day of Month: 1-31
Months: 0-11
Day of Week: 0-6

参考:https://github.com/ncb000gt/node-cron

如果您不关心它在一天中的什么时间运行,我真的很想使用@weekly关键字运行。它应该在每个星期天运行,而且绝对更有可读性。

@weekly some_script.sh

以人类可读的方式使用crontab构建器的Cron作业表达式

下面是crontab文件的格式。

{分钟}{小时}{月日}{月日}{用户}{path-to-shell-script}

因此,在每个周日的午夜运行(周日通常是0,在一些罕见的情况下是7):

0 0 * * 0 root /path_to_command
* * * * 0 

you can use above cron job to run on every week on sunday, but in addition on what time you want to run this job for that you can follow below concept :

* * * * *  Command_to_execute
- � � � -
| | | | |
| | | | +�� Day of week (0�6) (Sunday=0) or Sun, Mon, Tue,...
| | | +���- Month (1�12) or Jan, Feb,...
| | +����-� Day of month (1�31)
| +������� Hour (0�23)
+��������- Minute (0�59)