如何设置cronjob 2天? [英] how to set cronjob for 2 days?
问题描述
我们想使用cronjob创建数据库备份。
We would like to use a cronjob to create a database backup.
备份应该每两天进行一次。可以使用以下cron条目吗?
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.
A 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 * *
)会在每月的每个月的第二个午夜运行该命令。
What you've got (0 0 2 * *
) will run the command on the 2nd of the month at midnight, every month.
ps您的答案中似乎还有一个星号。格式应为:
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屋!