Spring cron expression for every day 1:01:am

后端 未结 6 902
南方客
南方客 2020-11-28 00:08

I\'m trying to have my code execute on a fixed schedule, based on a Spring cron expression. I would like the code to be executed every day at 1:01:am. I tried the following

6条回答
  •  再見小時候
    2020-11-28 00:38

    Something missing from gipinani's answer

    @Scheduled(cron = "0 1 1,13 * * ?", zone = "CST")
    

    This will execute at 1.01 and 13.01. It can be used when you need to run the job without a pattern multiple times a day.

    And the zone attribute is very useful, when you do deployments in remote servers. This was introduced with spring 4.

提交回复
热议问题