Question

I am developing java application and in this i wanted to run some method periodically. I have used java schedule to run that method periodically. This is my Cron Expression.

public static String CRON_TIME = "2 0/10 0-9.30,11.30-23 * * ?"; /* This should run in every 10 minutes excluding 10.30am to 11.30am(1 hour)*/

This is not works as i expected. How I can write Cron Expression to do it? Give me a idea.

Was it helpful?

Solution

Your expression will not work as the hours range includes minutes (0-9.30, 11.30-23)

You will need to set up multiple triggers calling the same method.

  1. every 10 minutes for hours 0-8 (2 0/10 0-8 * * ?)
  2. 0/10/20 for hour 9 (2 0,10,20 9 * * ?)
  3. 40/50 for hour 11 (2 40,50 11 * * ?)
  4. every 10 minutes for hours 12-23 (2 0/10 12-23 * * ?)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top