java - Java cron中问号的意义

标签 java cron crontab

来源维基百科:

Question mark (?) is used instead of '*' for leaving either day-of-month or day-of-week blank.

上述说法对我来说没有多大意义。

所以如果我写一些 cron 作为 0 0 0 ? * * 那么它是指每个月的第一天还是意味着它将每天执行?

这有点令人困惑,因为 Java crons 以秒开头,而其他 crons 以分钟开头。

最佳答案

根据Quartz CronTrigger tutorial (Quartz 被 www.cronmaker.com 使用,如上所引用),? 通配符仅用于月日和星期几字段:

? ("no specific value") - useful when you need to specify something in one of the two fields in which the character is allowed, but not the other. For example, if I want my trigger to fire on a particular day of the month (say, the 10th), but don't care what day of the week that happens to be, I would put "10" in the day-of-month field, and "?" in the day-of-week field.

我猜 * 在这里不合适,因为 * 意味着在一周中的每一天执行,这与它应该只在 10 日运行的规则相矛盾月份。

关于java - Java cron中问号的意义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11499740/

相关文章:

java - 使用JLayer播放mp3资源

Java - 将List转换为Map并在内部合并重复的关键数据

java - 我试图从 cronjob 调用 gradle,但它似乎没有被执行

crontab - cloud9.ide有时间限制吗?

linux - crontab 在某些时间之间每 15 分钟运行一次

java - 在 Java 中格式化字符串输出

java - JSoup 从 unix 中的 HTML 选择

bash - 从 cron 作业创建空的 catalina.out(基于刚刚删除的 catalina.out)

mysql - 带日期的 Cron 文件名正在传递 Y_m_d 而不是实际日期

linux - cron 作业的服务器使用情况是什么?