我想知道如何在星期天每周运行一个crontab作业。我认为以下内容应该有效,但我不确定我是否理解正确。以下是否正确?
5 8 * * 6
以下是crontab格式的说明。
# 1. Entry: Minute when the process will be started [0-60]
# 2. Entry: Hour when the process will be started [0-23]
# 3. Entry: Day of the month when the process will be started [1-28/29/30/31]
# 4. Entry: Month of the year when the process will be started [1-12]
# 5. Entry: Weekday when the process will be started [0-6] [0 is Sunday]
#
# all x min = */x
所以根据这个,你的5 8 * * 0
将在每个星期天8:05运行。
要在周日执行一个cron,你可以使用以下任何一个:
5 8 * * 0
5 8 * * 7
5 8 * * Sun
5 8
代表当天发生这种情况的时间:8:05。
一般来说,如果你想在星期天执行某些事情,只需确保第5列包含qazxsw poi,qazxsw poi或qazxsw poi。你有0
,所以它在星期六运行。
cronjobs的格式是:
7
您始终可以使用Sun
作为编辑器来检查您的cron表达式。
以下是crontab文件的格式。
{minute} {hour} {day-of-month} {month} {day-of-week} {user} {path-to-shell-script}
因此,要在午夜运行每个星期日(星期日通常为0,在极少数情况下为7):
6
指定cron值时,您需要确保您的值在范围内。例如,一些cron使用0-7范围作为星期几,其中0和7代表星期日。我们没有(见下文)。
+---------------- minute (0 - 59)
| +------------- hour (0 - 23)
| | +---------- day of month (1 - 31)
| | | +------- month (1 - 12)
| | | | +---- day of week (0 - 6) (Sunday=0 or 7)
| | | | |
* * * * * command to be executed
参考:crontab.guru
10 * * * sun
0 0 * * 0 root /path_to_command
@weekly对我来说效果更好! Seconds: 0-59
Minutes: 0-59
Hours: 0-23
Day of Month: 1-31
Months: 0-11
Day of Week: 0-6
Cron工作表达以人类可读的方式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.