cron job that will never execute

前端 未结 5 1028
耶瑟儿~
耶瑟儿~ 2020-12-05 22:22

Is there any way to create a cron expression for not running the job at all. I though of using this expression :

0 0 0 1 1 ? 3099

5条回答
  •  长情又很酷
    2020-12-05 23:12

    I needed a valid cron schedule (? syntax not working in my system) which resolves real dates, but to be effectively "never". My current best solution was to pick the most recent leap year and see what day Feb 29th fell on. Feb 29 2016 was a Monday, so the next Monday Feb 29 is currently furthest away.

    0 0 29 2 1 yields the next 5 triggers as:

    02/29/2044 00:00:00Z
    02/29/2072 00:00:00Z
    02/29/2112 00:00:00Z
    02/29/2140 00:00:00Z
    02/29/2168 00:00:00Z
    

    Not perfect but it'll do.

提交回复
热议问题