Is there a difference between ? and * in cron expressions? Strange example

后端 未结 3 1947
误落风尘
误落风尘 2020-12-14 07:55

I have the following cron expression in my system:

0 0 0/1 1/1 * ? *

and you know what? I have no idea what it means. The guy who has writt

3条回答
  •  佛祖请我去吃肉
    2020-12-14 08:40

    Not an answer, just an update to the correct answer of @joc.

    As for now, QuartzScheduler specifically points it out that ? could be applied in one of the two positions: day_of_month or day_of_week.

    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).

    Besides in the link enclosed above, there are lots of examples to guide you well enough to come up with your own.

    
    +--------------------+-------------------------------------------------------------------------------------------------------------------------------------+
    |   **Expression**   |                                                             **Meaning**                                                             |
    +--------------------+-------------------------------------------------------------------------------------------------------------------------------------+
    | 0 0 12 * * ?       | Fire at 12pm (noon) every day                                                                                                       |
    | 0 15 10 ? * *      | Fire at 10:15am every day                                                                                                           |
    | 0 15 10 * * ?      | Fire at 10:15am every day                                                                                                           |
    | 0 15 10 * * ? *    | Fire at 10:15am every day                                                                                                           |
    | 0 15 10 * * ? 2005 | Fire at 10:15am every day during the year 2005                                                                                      |
    | 0 * 14 * * ?       | Fire every minute starting at 2pm and ending at 2:59pm, every day                                                                   |
    | 0 0/5 14 * * ?     | Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day                                                                |
    | 0 0/5 14,18 * * ?  | Fire every 5 minutes starting at 2pm and ending at 2:55pm, AND fire every 5 minutes starting at 6pm and ending at 6:55pm, every day |
    +--------------------+-------------------------------------------------------------------------------------------------------------------------------------+
    
    

提交回复
热议问题