3

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 ?

saij9999
  • 282
  • 1
  • 3
  • 18

1 Answers1

5

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
  • 15,854
  • 5
  • 53
  • 88