0

I have a requirement where I want to execute a particular spring boot application n number of times based upon the number (n) provided in the parameter. I am using spring boot and thought of using spring scheduler to do this. Can spring scheduler be used to schedule a task for 4-5 times and then stop ?

I need to have a separate log file, output files generated for each instance.

1 Answers1

0

I think you can do it with the help of this answer: https://stackoverflow.com/a/30347649/13184919

You should make a counter by initializing an int counter = 0; and increase it every time it runs, then checks if it is more than your desired number and you call scheduledFuture.cancel(true);

Máté Tősér
  • 296
  • 2
  • 9