I'm working with @Scheduled annotation in Spring 3 . I need to run some tasks every week or every two weeks, so i'm using cron expression as parameter eg
@Scheduled("0 0 2 */7 * *")
My question is if i will create scheduled task that must run every 7 days and on the 6-th day i will restart server (with war redeploy) will it reset this scheduled task (and i need to wait 7 days again) or it saves its state and will trigger this task on 7-th anyway?
Not sure what */7
means but I'm sure that 1/7
in the following cron means:
Fires at 2am every 7 days every month starting on the first day of the month
@Scheduled("0 0 2 1/7 * ?")
I'm pretty certain it won't survive a JVM restart.
If you want the job to run every seven days you're probably better scheduling it from cron ( or similar external scheduling mechanism ) rather than getting Spring to do it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.