spring scheduled task run every second with cron(0 0/10 * * * ? )
Asked Answered
K

2

17

it's strange, i setup corn as

@Scheduled(cron= "0 0/10 *  * * ? ")

It did trigger every 10 minutes, but the issue is task runs each second.

Kirchner answered 3/4, 2014 at 8:7 Comment(0)
K
18

This is what javadoc says :

CronSequenceGenerator

the first field of the cron is for seconds.

Kibitzer answered 29/6, 2016 at 6:46 Comment(3)
How to make it run every second ?Deliladelilah
Doc says "*/10 * * * * *" = every ten seconds. so the expression for every second would be "*/1 * * * * *"Graticule
I tried your suggestion, @Graticule and have to say that in my case the job runs every ten minutes, not secondsPhotocell
B
5

If you want to execute every 10 seconds, you should have this:

@Scheduled(cron= "0/10 * * ? * *")
Bronwynbronx answered 18/10, 2023 at 10:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.