2

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 ?

raj_kumar_junior
  • 234
  • 2
  • 14

1 Answers1

4

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

ch271828n
  • 13,130
  • 3
  • 38
  • 64