1

what is the best way to run function each 10 minutes directly in hh:m5 (00:05,00:15,00:25,...,23:55). Is it reliable to use scheduler which starts at 00:05 and have period of 10 minutes? I mean something like

Date date0005 = new java.util.Date();

date0005.setHour(00);
date0005.setMinutes(05);
// instead of this here can be function to found nearest hh:m5 from run

Timer timer = new Timer();

timer.sc(myOwnTimerTask,date0005, 600000);

Will it works after for example 1 month of continuous run? I mean, will function be called for example still at hh:m5 and not at hh:m6?

Or is better to do function, which runs every 31-60 seconds, which can control last digit of hh:mm and if there is 5, then it calls the function?

Or is there any better way?

SilentCry
  • 1,902
  • 3
  • 16
  • 23
  • 2
    Timing in java (and many other languages) is flexible. you can not guarantee that it will run every 10 minutes, but you can guarantee that the next time it runs will be no less than 10 minutes from when you set the timer. Check out this post: http://stackoverflow.com/questions/20387881/how-to-run-certain-task-every-day-at-a-particular-time-using-scheduledexecutorse – DwB Jun 01 '16 at 13:45

1 Answers1

0

Use CronJobs with the following parameter (CronSchedule parameter)

"0 0/5 * * * ?"
cihan adil seven
  • 541
  • 1
  • 4
  • 20