只是想知道这是一个正确的@Scheduled cron表达式,如果你希望它在晚上21点到早上6点之间每三分钟运行一次:
@Scheduled(cron = "0 */3 21-6 * * ?")
它会跑过夜吗?
答案 0 :(得分:1)
我认为它应该是<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<div class="col-md-4">
<h4 class="sub-header" id="product_type">Product Type</h4>
<form>
<div class="radio"><label><input type="radio" name="product_type" value="Laptop">Laptop</label></div>
<div class="radio"><label><input type="radio" name="product_type" value="Tower">Tower</label></div>
<div class="radio"><label><input type="radio" name="product_type" value="Minitower">Minitower</label></div>
<div class="radio"><label><input type="radio" name="product_type" value="Small Form Factor">Small Form Factor</label></div>
</form>
</div><!-- /.col-lg-4 Product Type-->
<div class="text-center" id="test">
<button target="_blank"
class="btn btn-primary ">
Test
</button>
</div>
答案 1 :(得分:1)
我想应该是@Scheduled(cron="0 */3 21-23,0-6 * * ?")
。请查看 this video 以了解使用 cron 表达式的不同可能方式。
答案 2 :(得分:0)
如果您希望 cron 在 6:00 停止,则必须在范围内写入 5 而不是 6,否则将包括整个小时,因此:
@Scheduled(cron="0 */3 21-23,0-5 * * *")
我发现 this website 非常有助于帮助您编写适用于 Spring 格式的 cron 表达式。
它给出了这样的解释:每 3 分钟,在 09:00 PM 到 11:59 PM 和 12:00 AM 到 05:59 AM