如何将 cronjob 设置为 2 天? [英] how to set cronjob for 2 days?
问题描述
我们想使用 cronjob 来创建数据库备份.
We would like to use a cronjob to create a database backup.
备份应该每两天进行一次.可以使用以下cron-entry吗?
The backup should occur ones every two days. Can the following cron-entry be used?
0 0 2 * * * backup-command
如果这是错误的,请告诉我设置 cron 2 天的正确命令.
If this is wrong please tell me the correct command for setting the cron for 2 days.
推荐答案
来自 这里:
Cron 还支持 'step' 值.
Cron also supports 'step' values.
dom 字段中的 */2
值将意味着该命令每两天运行一次同样,小时字段中的 */5
将意味着该命令每 5 次运行一次小时.例如
A value of */2
in the dom field would
mean the command runs every two days
and likewise, */5
in the hours field
would mean the command runs every 5
hours. e.g.
* 12 10-16/2 * * root backup.sh
等同于:
* 12 10,12,14,16 * * root backup.sh
所以我想你想要0 0 */2 * *
.
您所拥有的 (0 0 2 * *
) 将在每月 2 日午夜运行该命令.
What you've got (0 0 2 * *
) will run the command on the 2nd of the month at midnight, every month.
附言您的答案中似乎多了一个星号.格式应为:
p.s. You seem to have an extra asterisk in your answer. The format should be:
minute hour dom month dow user cmd
因此,您的额外星号将位于 user
字段中.这是故意的吗?
So your extra asterisk would be in the user
field. Is that intended?
这篇关于如何将 cronjob 设置为 2 天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!