Spring boot run cron job only once after Every restart of the App

Viewed 1624

i have spring boot project with a cron job. the job should be run only once. it should trigger again only if app is crashed or app is restarted. is there any cron expression for this ? or any way to achieve this ?

1 Answers

If run once when app start, that is not a cron IMHO... Actually you only need to run it when you application finishes booting. Thus, listen to the application booted event, and run your code then. For example, this one: Running code after Spring Boot starts

Related