MickeyThreeSheds
MickeyThreeSheds

Reputation: 1016

Spring scheduled tasks - making them run every day at 3am?

I have the following line of scheduling in spring...

        <task:scheduled ref="jobService" method="jobToRun" cron="0 0 7 ? * MON" />

I now have the need to make this happen every single day (including weekends) at 3am - I've no idea what I am looking at here, Cron has always kind of escaped me = I know I need to change the "0 0 7 ? * MON" string, but I have no idea what it should be... All help appreciated! Thanks in advance. I tried googling this, but there seemes to be multiple formats etc - I am not too sure what exactly I need it to be.

Upvotes: 2

Views: 3692

Answers (1)

Vasu
Vasu

Reputation: 22412

You need to change the cron as shown below:

<task:scheduled ref="jobService" method="jobToRun" cron="0 0 3 * * *" />

The cron expression represents the below time:

0 - 0 seconds

0 - 0 minutes

3 - 3AM

Rest of the * fields in the cron indicates all over the year, all weeks and days

I suggest you understand the cron expression patterns from here

Upvotes: 3

Related Questions