Spring Cron periodic expression: to run every 3 hours

I want my spring job to run every 3 hours

Did I use the expression * * */3 * * ? that starts the task per hour, which is divided by 3, for example. They say that the server was started at 2 p.m., work starts only at 3 p.m. - while it's so good, but the work starts every second! Is it because I used * in 1st position?

I tried 0 0 */3 * * ? but this is a mistake. What is the best way to achieve this?

+6
source share
2 answers

Format

second, minute, hour, day, month, weekday

therefore the correct cron expression should be

 0 0 */3 * * * 

If this does not work, what exact error message do you get?

+15
source

The correct syntax to run the script every 3 hours:

 0 0 0/3 * * ? 
+8
source

Source: https://habr.com/ru/post/926493/


All Articles