第 3、9、15、21 小时的 Quartz Cron 表达式

Quartz Cron Expression for Hours 3, 9, 15, 21

我正在使用 Quartz Grails 插件,我需要安排一个作业在每天凌晨 3 点、上午 9 点、下午 3 点、晚上 9 点运行。这似乎是一个有效的 cron 表达式:

* 3,9,15,21 * * *

但是 Quartz 不支持。我需要做的事情可行吗?

Quartz中,表达式多了一个位置。第一个代表秒,而不是分钟,因为它用于 unix 风格的 cron 表达式。另一个问题是石英支持指定星期几和月份:

Support for specifying both a day-of-week and a day-of-month value is not complete (you must currently use the '?' character in one of these fields).

这应该有效:

* * 3,9,15,21 * * ?

查看此guide and the Quartz grails docs了解更多详情。