Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
801 views
in Technique[技术] by (71.8m points)

cron - how to set cronjob for 2 days?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From here:

Cron also supports 'step' values.

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

is the same as:

* 12 10,12,14,16 * * root backup.sh

So I think you want 0 0 */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

So your extra asterisk would be in the user field. Is that intended?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...