Reputation: 175
I am new to Spring. I am trying to run a cron job every hour and I am using the
@Scheduled(cron="0 0/60 * * * ?")
expression for this. So when does the job start? Lets say if i have deployed the application at 10:03 AM. Will the cron Job start at the next hour i.e., 11:00 AM or it starts at 10:03 AM first and then from the next consecutive hours like 11:00, 12:00 and so on..?
Actually I deployed my application yesterday and I don't see the cron job running. I am trying to figure it out why it's not running. Meanwhile I just want to clarify myself.
I have tried to follow the documentation, but I believe they didn't mention this in the documentation: https://docs.spring.io/spring/docs/current/spring-framework-reference/html/scheduling.html
Upvotes: 5
Views: 1739
Reputation: 12453
It will execute at every hour, minute 0 (same as 60), second 0 (hh:00:00). So "cron="0 0 * * * ?"
, will also do.
The /
between values defines a range, so "cron="0 30/45 * * * ?"
will execute when minute is 30 and then 15 times, until minute passes 45.
If no cron job is executed at all, it seems scheduling is not started at all. Did you set the @EnableScheduling
annotation in your config?
To test the availability, set it to cron = "* * * * * ?"
(every second).
Upvotes: 3