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.
我正在开发java应用程序,在此我想定期运行一些方法。我已经使用java schedule定期运行该方法。这是我的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)*/
public static String CRON_TIME =“2 0/10 0-9.30,11.30-23 * *?”; / *这应该每10分钟运行一次,不包括上午10:30至11:30(1小时)* /
This is not works as i expected. How I can write Cron Expression to do it? Give me a idea.
这不符合我的预期。我怎么能写Cron Expression来做呢?给我一个主意。
1 个解决方案
#1
0
Your expression will not work as the hours range includes minutes (0-9.30, 11.30-23)
您的表达不起作用,因为小时范围包括分钟(0-9.30,11.30-23)
You will need to set up multiple triggers calling the same method.
您需要设置多个调用相同方法的触发器。
- every 10 minutes for hours 0-8 (2 0/10 0-8 * * ?)
- 0/10/20 for hour 9 (2 0,10,20 9 * * ?)
- 40/50 for hour 11 (2 40,50 11 * * ?)
- every 10 minutes for hours 12-23 (2 0/10 12-23 * * ?)
每10分钟0-8小时(2 0/10 0-8 * *?)
小时9分0/10/20(2 0,10,20 9 * *?)
小时11的40/50(2 40,50 11 * *?)
小时12-23(10 0/10 12-23 * *?)每10分钟一次
#1
0
Your expression will not work as the hours range includes minutes (0-9.30, 11.30-23)
您的表达不起作用,因为小时范围包括分钟(0-9.30,11.30-23)
You will need to set up multiple triggers calling the same method.
您需要设置多个调用相同方法的触发器。
- every 10 minutes for hours 0-8 (2 0/10 0-8 * * ?)
- 0/10/20 for hour 9 (2 0,10,20 9 * * ?)
- 40/50 for hour 11 (2 40,50 11 * * ?)
- every 10 minutes for hours 12-23 (2 0/10 12-23 * * ?)
每10分钟0-8小时(2 0/10 0-8 * *?)
小时9分0/10/20(2 0,10,20 9 * *?)
小时11的40/50(2 40,50 11 * *?)
小时12-23(10 0/10 12-23 * *?)每10分钟一次