0
votes

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 e.g.

@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?

2

2 Answers

0
votes

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 * ?")
0
votes

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.