To set the script to run hourly, we select the 'Repeat task…' option and enable it. We select the '1 hour' option, indicating that we wish for the task to execute on an hourly basis, and select the duration as indefinite under the duration option.
The @EnableScheduling annotation is used to enable the scheduler for your application. This annotation should be added into the main Spring Boot application class file. @SpringBootApplication @EnableScheduling public class DemoApplication { public static void main(String[] args) { SpringApplication.
This task is executed at 22:45:00 every day, every week, every month.
To execute a task every minute, use
0 * * * * *
The accepted answer is correct for spring. Other than that, one should be careful whether the target system uses 6 or 5-digits cron.
With 5-digits-crons
0 * * * *
schedules to be run "at minute 0" (hence every hour).
The correct answer in this case should be either
* * * * *
or
*/1 * * * *
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With