Significance of question mark in Java cron

后端 未结 2 1311
借酒劲吻你
借酒劲吻你 2020-12-08 12:56

Source Wikipedia:

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

2条回答
  •  醉话见心
    2020-12-08 13:37

    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

    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.

    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:

    Time: 25 8 * * * *

提交回复
热议问题