特定日期的Cron表达式

编程入门 行业动态 更新时间:2024-10-28 16:17:08
本文介绍了特定日期的Cron表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想要一个代表2010年9月6日的cron表达6:00 am

I want a cron expression that represents 6th September 2010 6:00 am

推荐答案

原始问题标记为 cron 所以这第一部分适用于此。有关Quartz CronTrigger工具的更新答案,请参见下文。

Original question was tagged cron so this first section applies to that. See below for an updated answer for the Quartz CronTrigger tool.

大多数crontab不允许您指定年份可能不得不将它放在脚本本身(或脚本/程序周围的包装)中。

Most crontabs don't let you specify the year so you'll probably have to put that in the script itself (or a wrapper around the script/program).

你可以这样做:

if [[ $(date +%Y) != 2010 ]] ; then exit fi

您要查找的选项9月6日上午6点每个年份是

The option you're looking for to run at 6am on September 6 every year is

0 6 6 9 * your_command_goes_here | | | | | | | | | +- any day of the week. | | | +--- 9th month (September). | | +----- 6th day of the month. | +------- 6th hour of the day. +--------- Top of the hour (minutes = 0).

对于Quartz CronTrigger格式,你会看起来像:

For the Quartz CronTrigger format, you'd be looking at something like:

0 0 6 6 9 ? 2010 | | | | | | | | | | | | | +- 2010 only. | | | | | +----- any day of the week. | | | | +------- 9th month (September). | | | +--------- 6th day of the month. | | +----------- 6th hour of the day. | +------------- Top of the hour (minutes = 0). +--------------- Top of the minute (seconds = 0).

(从 here )。

更多推荐

特定日期的Cron表达式

本文发布于:2023-11-24 08:37:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624498.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表达式   日期   Cron

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!