Spring cron expression for every after 30 minutes

前端 未结 5 1668
南笙
南笙 2021-01-30 06:33

I have following Spring job to run after every 30 minutes. Please check my cron expression, is that correct?

\"0 0 0 * * 30\"


H

5条回答
  •  情深已故
    2021-01-30 07:09

    Graphically, the cron syntax for Quarz is (source):

    +-------------------- second (0 - 59)
    |  +----------------- minute (0 - 59)
    |  |  +-------------- hour (0 - 23)
    |  |  |  +----------- day of month (1 - 31)
    |  |  |  |  +-------- month (1 - 12)
    |  |  |  |  |  +----- day of week (0 - 6) (Sunday=0 or 7)
    |  |  |  |  |  |  +-- year [optional]
    |  |  |  |  |  |  |
    *  *  *  *  *  *  * command to be executed 
    

    So if you want to run a command every 30 minutes you can say either of these:

    0 0/30 * * * * ?
    0 0,30 * * * * ?
    

    You can check crontab expressions using either of these:

    • crontab.guru — (disclaimer: I am not related to that page at all, only that I find it very useful). This page uses UNIX style of cron that does not have seconds in it, while Spring does as the first field.
    • Cron Expression Generator & Explainer - Quartz — cron formatter, allowing seconds also.

提交回复
热议问题