Reputation:
I have to write a spring scheduler which runs once in a week , say every Monday at 1 AM .What will be the cron expression for that , can we archive this using fixedDely.
Upvotes: 3
Views: 14161
Reputation: 73241
A fixed delay is a delay, not a recurring event. With fixedDelay
you could setup an event that runs after a fixed period in milliseconds between the end of the last invocation and the start of the next. That's not what you want here.
To have a job run every monday at 1 AM you can setup a cron
expression
@Scheduled(cron = "0 0 1 * * MON")
Upvotes: 2
Reputation: 18235
You can use cron for that:
@Scheduled(cron = "0 0 1 * * MON")
In order from left to right of a cron expression:
second, minute, hour, day of month, month, day(s) of week
Upvotes: 15