Reputation: 71
I made many searches over internet about an option mentioned by Baeldung here, but I can't find any example. I would like to use something like this:
@Scheduled(cron="@reboot")
@Scheduled(cron="0 0 5 * * *")
public void somethingToDoOnRebootTime() {
// code here, to run every day at 5a.m., AND at boot first time...
}
But it didn't work, 'cause "@reboot" is not a valid cron expression... I tried to use this "@reboot" as a normal annotation to the method, but it didn't exists too...
Someone can help me? Is the article on Baeldung wrong?
Upvotes: 0
Views: 1007
Reputation: 71
Based on @M.Deinum comment... I used ApplicationListener but with ApplicationReadyEvent! So, my example becames:
@EventListener(ApplicationReadyEvent.class)
@Scheduled(cron="0 0 5 * * *")
public void somethingToDoOnRebootTime() {
// code here, to run every day at 5a.m., AND at boot first time...
}
Upvotes: 2