Cron expression to run every N minutes

前端 未结 4 1527
傲寒
傲寒 2020-12-11 04:21

I need to build a cron expression to run a job every 10 minutes after the user click on start button.

I\'m trying to do something like:

0 42/10 * * *         


        
4条回答
  •  醉话见心
    2020-12-11 04:35

    I think your format is wrong. The order of the fields is:

    1. Minute
    2. Hour
    3. Day of Month
    4. Month
    5. Day of Week
    6. Command

    So in your example, the Minute is 0, and your Hour is invalid (Hour must be in the range 0-23). I'm guessing cron is ignoring the incorrect Hour, and running on Minute 0 of every hour.

    However, if you did want to run every N minutes, you could use a format like (where N is less than 60):

    0/N * * * * /bin/echo "Your Command Here"
    

    However, keep in mind that the /N repeats the command every N minutes within the current hour. So, if you have 0/33 in your crontab your command will run at:

    • 00:00
    • 00:33
    • 01:00
    • 01:33

    Not at:

    • 00:00
    • 00:33
    • 01:06
    • 01:39

提交回复
热议问题