热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

JavaCron中问号的重要性-SignificanceofquestionmarkinJavacron

SourceWikipedia:Questionmark(?)isusedinsteadof*forleavingeitherday-of-monthord

Source Wikipedia:

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

使用问号(?)代替'*'来保留日期或星期几空白。

The above statement is not making much sense to me.

上面的陈述对我来说没有多大意义。

So if I write some cron as 0 0 0 ? * * then does it mean first of every month or it means it will execute daily?

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

It is a bit confusing as Java crons start with seconds while other crons start with minute.

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

3 个解决方案

#1


-8  

I am not Cron expert

我不是Cron专家

But according www.cronmaker.com it is executed daily.

但根据www.cronmaker.com,它每天执行。

#2


70  

According to the Quartz CronTrigger tutorial (Quartz is used by www.cronmaker.com, referenced above), the ? wildcard is only used in the day of month and day of week fields:

根据Quartz CronTrigger教程(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天)触发,但不关心恰好在一周的哪一天,我会在当天放置“10” -month字段,和“?”在星期几的字段中。

I guess * isn't appropriate here because * means execute on every day of the week, which contradicts the rule saying that it should only run on the 10th of the month.

我想这里*是不合适的,因为*意味着在每周的每一天都执行,这违反了规则,它应该只在该月的10日运行。

#3


-3  

I know it's an old question but for posterity, it's explained here : http://www.nncron.ru/help/EN/working/cron-format.htm#STARTTIME

我知道这是一个古老的问题,但对后代而言,这里有解释:http://www.nncron.ru/help/EN/working/cron-format.htm#STARTTIME

Both in classic and extended modes, nnCron users can use a "nonstandard" character "?" in the first four fields of cron format. It stands for time of nnCron startup, i. e. when a field is processed, startup time will be substituted for the question mark: minutes for Minute field, hour for Hour field, day of the month for Day of month field and month for Month field.

在经典模式和扩展模式下,nnCron用户都可以使用“非标准”字符“?”在cron格式的前四个字段中。它代表nnCron启动的时间,i。即处理字段时,启动时间将替换问号:分钟字段分钟,小时字段小时,月日字段月份日期和月份字段月份。

For example, if you write the following:

例如,如果您编写以下内容:

Time: ? ? * * * * the task will be executed on nnCron startup and then will be executed daily at the same time (unless the user doesn't restart nnCron, of course): question marks will be "replaced" by nnCron startup time. For example, if nnCron was started at 8:25, question marks will be substituted this way:

时间: ? ? * * * *任务将在nnCron启动时执行,然后每天同时执行(当然,除非用户没有重启nnCron):问号将被nnCron启动时间“替换”。例如,如果nnCron在8:25启动,则问号将以这种方式替换:

Time: 25 8 * * * *

时间:25 8 * * * *


推荐阅读
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • VScode格式化文档换行或不换行的设置方法
    本文介绍了在VScode中设置格式化文档换行或不换行的方法,包括使用插件和修改settings.json文件的内容。详细步骤为:找到settings.json文件,将其中的代码替换为指定的代码。 ... [详细]
  • IjustinheritedsomewebpageswhichusesMooTools.IneverusedMooTools.NowIneedtoaddsomef ... [详细]
  • 本文介绍了在MFC下利用C++和MFC的特性动态创建窗口的方法,包括继承现有的MFC类并加以改造、插入工具栏和状态栏对象的声明等。同时还提到了窗口销毁的处理方法。本文详细介绍了实现方法并给出了相关注意事项。 ... [详细]
  • 小程序wxs中的时间格式化以及格式化时间和date时间互转
    本文介绍了在小程序wxs中进行时间格式化操作的问题,并提供了解决方法。同时还介绍了格式化时间和date时间的互相转换的方法。 ... [详细]
  • Gitlab接入公司内部单点登录的安装和配置教程
    本文介绍了如何将公司内部的Gitlab系统接入单点登录服务,并提供了安装和配置的详细教程。通过使用oauth2协议,将原有的各子系统的独立登录统一迁移至单点登录。文章包括Gitlab的安装环境、版本号、编辑配置文件的步骤,并解决了在迁移过程中可能遇到的问题。 ... [详细]
  • 本文介绍了贝叶斯垃圾邮件分类的机器学习代码,代码来源于https://www.cnblogs.com/huangyc/p/10327209.html,并对代码进行了简介。朴素贝叶斯分类器训练函数包括求p(Ci)和基于词汇表的p(w|Ci)。 ... [详细]
  • 本文介绍了Java类的访问级别,包括public、private、protected和package-private,并重点解释了package-private的含义和作用。package-private表示类只能在其所在的包内可见,而不能被其他包的类访问。该文章还提到了其他访问级别的作用和范围,并对Java类的可见性进行了详细说明。 ... [详细]
  • 本文整理了Java中org.apache.solr.common.SolrDocument.setField()方法的一些代码示例,展示了SolrDocum ... [详细]
  • Summarize function is doing alignment without timezone ?
    Hi.Imtryingtogetsummarizefrom00:00otfirstdayofthismonthametric, ... [详细]
  • 使用这个技巧要达到的目标:一般来说,模型和控制器你都不会有相同的类名字。让我先创建一个取名为post的model。classPostextendsModel{}现在 ... [详细]
  • 本文介绍了Windows操作系统的版本及其特点,包括Windows 7系统的6个版本:Starter、Home Basic、Home Premium、Professional、Enterprise、Ultimate。Windows操作系统是微软公司研发的一套操作系统,具有人机操作性优异、支持的应用软件较多、对硬件支持良好等优点。Windows 7 Starter是功能最少的版本,缺乏Aero特效功能,没有64位支持,最初设计不能同时运行三个以上应用程序。 ... [详细]
  • Android工程师面试准备及设计模式使用场景
    本文介绍了Android工程师面试准备的经验,包括面试流程和重点准备内容。同时,还介绍了建造者模式的使用场景,以及在Android开发中的具体应用。 ... [详细]
  • 本文介绍了使用哈夫曼树实现文件压缩和解压的方法。首先对数据结构课程设计中的代码进行了分析,包括使用时间调用、常量定义和统计文件中各个字符时相关的结构体。然后讨论了哈夫曼树的实现原理和算法。最后介绍了文件压缩和解压的具体步骤,包括字符统计、构建哈夫曼树、生成编码表、编码和解码过程。通过实例演示了文件压缩和解压的效果。本文的内容对于理解哈夫曼树的实现原理和应用具有一定的参考价值。 ... [详细]
author-avatar
凹凸妖精铺子
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有