crontab执行时间计算

0 */12 * * * [user] [command] 请只输入红色部分。

接下来7次的执行时间:

例子:
# 每月的最后1天
0 0 L * * *

说明:
Linux
*    *    *    *    *    *
-    -    -    -    -    -
|    |    |    |    |    |
|    |    |    |    |    + year [optional]
|    |    |    |    +----- day of week (0 - 7) (Sunday=0 or 7)
|    |    |    +---------- month (1 - 12)
|    |    +--------------- day of month (1 - 31)
|    +-------------------- hour (0 - 23)
+------------------------- min (0 - 59)
例子:
# 每月的最后1天
@Scheduled(cron = "0 0 18 28–31 * ?")
public void doAtLastDayOfMonth() {
    final Calendar calendar = Calendar.getInstance();
    if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DATE)) {
        // do something here...
    }
}

说明:
Java(Spring)
*    *    *    *    *    *    *
-    -    -    -    -    -    -
|    |    |    |    |    |    |
|    |    |    |    |    |    + year [optional]
|    |    |    |    |    +----- day of week (0 - 7) (Sunday=0 or 7)
|    |    |    |    +---------- month (1 - 12)
|    |    |    +--------------- day of month (1 - 31)
|    |    +-------------------- hour (0 - 23)
|    +------------------------- min (0 - 59)
+------------------------------ second (0 - 59)

😉 阿里云幸运券,戳我领取

联系我 - 工具首页
Copyright © 2011-2019 iteam. All Rights Reserved. Current version is 2.52.0.
浙ICP备14020137号 $访客地图$