Cron format helper

This utility helps you build Cron expressions easily by choosing job scheduling scenarios. The crontab entries produced work with Vixie Cron, popular in many Linux distributions.

Loading utility...

Vixie Cron - a quick overview

Vixie Cron is configured by editing a "crontab" file that indicates the date and times to run given commands. Each user of the system can have their own crontab file and there is also a system-wide crontab file.

The system-wide file is usually located under the "/etc" directory and called "crontab". Changes to this file are checked and reloaded automatically but changes to user-specific crontab files wont get picked up unless you reload them with the crontab command.

The beginning of the /etc/crontab file usually has some environment variable settings. Below that each line in the file gives the information for a particular job to run. A typical crontab line looks something like this:

The user field ("some-user" above) is specific to the system-wide crontab file. This field isnt necessary for user-specific crontab files as commands are run as the owning user.

The command field ("some-command" above) may be a straight-forward shell command or an executable script. The path to use to locate the script can be given in the PATH environment variable in the crontab file or you can give absolute paths.

The bit that this utility is designed to assist with is the Cron expression. It consists of 5 fields that represent the following:

The values accepted for each field are: The minute field value must be 0-59, the hour field 0-23, the day of month field 1-31, the month field 1-12 and the day of week field 0-6 (Sunday is 0 but this can also be given as 7). Days can be also be given as three letter abbreviations (sun, mon, tue, wed, thu, fri, sat) as can months (jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec) but you should be careful with these as some versions of Cron may not support them in ranges and lists (see below).

The values can be given in a variety of formats:

  • An asterisk (*) character will match all possible values for the field: e.g. the Cron expression "* * * * *" will run the command every minute since this is the smallest representable time period.
  • A literal value: e.g. "30 * * * *" will run the command whenever the minute is 30, i.e. once an hour at half-past the hour. 
    "* * 5 * *" will run every minute when it is the 5th day of the month.
  • A list is given by separating each possible value using a comma: e.g. "0,15,30,45 * * * *" will run the command whenever the minute is either 0, 15, 30 or 45. Another example, "0 1,2,3 * * *" will run the command between 1am and 3am (inclusive) but only when the minute is 0, i.e. on the hour. Lists can also contain ranges (see below).
  • A range is given by separating the lower and upper values of the range with a hyphen (-): e.g. "0 1 1-5 * *" will run the command at 1am on the first, second, third, fourth and fifth days of the month.
  • An increment is given by using a forward slash: e.g. "*/15 * * * *" will run the command every 15 minutes starting on the hour. i.e. this example is the same as the list example given above to run whenever the minute is 0, 15, 30 or 45.

Each of the possible formats above effectively resolves to a list of values to match. For example, if you use the * character in the day of week field it is the same as writing 1,2,3,4,5,6,7. Another example: putting */20in the minute field is like writing 0,20,40. This is important to remember as it is not possible to write something like */70 in the minute field and expect it to run every 70 minutes - it is invalid!

It also means you can get some unexpected behaviour - for example: say you put */40 in the minute field. This would not run every 40 minutes. It would actually run when the minute is 0 and when it is 40. So it would run 40 minutes after the hour and then again, 20 minutes later, on the next hour.

This utility produces true periodical expressions by only allowing factors of 60 or 24 for the minute/hour field respectively.

Hangfire定时任务设置CronExpression表达式的更多相关文章

  1. Quartz在Spring中动态设置cronExpression (spring设置动态定时任务)

    什么是动态定时任务:是由客户制定生成的,服务端只知道该去执行什么任务,但任务的定时是不确定的(是由客户制定).      这样总不能修改配置文件每定制个定时任务就增加一个trigger吧,即便允许客户 ...

  2. spring框架的定时任务cronExpression表达式详解

    附:cronExpression表达式解释: 0 0 12 * * ?---------------在每天中午12:00触发 0 15 10 ? * *---------------每天上午10:15 ...

  3. 关于cronExpression表达式

    spring 定时任务设置,关于cronExpression表达式: 字段 允许值 允许的特殊字符 秒 0-59 , - * / 分 0-59 , - * / 小时 0-23 , - * / 日期 1 ...

  4. Quartz.net 定时任务之Cron表达式

    一.cron表达式简单介绍和下载 1.在上一篇博客"Quartz.net 定时任务之简单任务"中,我简单介绍了quartz的使用,而这篇博客我将介绍cron的具体使用(不足之处望大 ...

  5. Quartz在Spring中动态设置cronExpression

    什么是动态定时任务:是由客户制定生成的,服务端只知道该去执行什么任务,但任务的定时是不确定的(是由客户制定). 这样总不能修改配置文件每定制个定时任务就增加一个trigger吧,即便允许客户修改配置文 ...

  6. JDK、Spring、Quartz等几种不同定时器的用法,以及cronExpression表达式定义

    referenc:https://blog.csdn.net/clementad/article/details/42042111 下面介绍几种常用的定时器及其实现方法: 第一种:Timer和Time ...

  7. 【Hadoop离线基础总结】oozie定时任务设置

    目录 简介 概述 oozie定时任务设置 1.拷贝定时任务的调度模板 拷贝hello.sh脚本 3.修改配置文件 4.上传到hdfs对应路径 5.运行定时任务 简介 概述 在oozie当中,主要是通过 ...

  8. Quartz中时间表达式的设置-----corn表达式

    Quartz中时间表达式的设置-----corn表达式 时间格式: <!-- s m h d m w(?) y(?) -->,   分别相应: 秒>分>小时>日>月 ...

  9. Quartz中时间表达式的设置-----corn表达式 (转)(http://www.cnblogs.com/GarfieldTom/p/3746290.html)

    Quartz中时间表达式的设置-----corn表达式 (注:这是让我看比较明白的一个博文,但是抱歉,没有找到原作者,如有侵犯,请告知) 时间格式: <!-- s m h d m w(?) y( ...

随机推荐

  1. peewee基本使用

    PEEWEE基本使用 Content Ⅰ  安装Ⅱ  链接数据库Ⅲ  建表 Ⅳ  增删改 Ⅴ  基础查询 Ⅵ  ForeignKey Ⅷ  事务 参考官方文档:http://docs.peewee-o ...

  2. Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并(转)

    Git Gui for Windows的建库.克隆(clone).上传(push).下载(pull).合并(转) from:http://hi.baidu.com/mvp_xuan/blog/item ...

  3. vshost32-clr2.exe 已停止工作

    软件中使用了DevComponents.DotNetBar2.dll MessageBoxEx.Show("ddd");运行到这句出现如上错误 解决:在项目属性里->调试: ...

  4. cf Round#273 Div.2

    题目链接,点击一下 Round#273 Div.2 ================== problem A Initial Bet ================== 很简单,打了两三场的cf第一 ...

  5. 数值计算 的bug:(理论)数学上等价,实际运行未必等价

    1. 计算表达式的值(lambda 表达式) fun1 和 fun2 理论上是等价的:同样的输入情形下,两种输出结果不一致. # fun1 定义 fun1=lambda x:sqrt(x+1)-sqr ...

  6. JavaScript大厦之JS运算符

    运算符用于执行程序代码运算,会针对一个及以上操作数项目来进行运算.2+3,其操作数是2和3,而运算符则是“+”.上一篇我们说过变量用来存储数据,而同一个变量中的数据在不同的时刻可以不同,在程序的运行过 ...

  7. Java面试题总结(附答案)

    1.什么是B/S架构?C/S架构? B/S(Browser/Server),浏览器/服务器程序: C/S(Client/Server),客户端/服务端,桌面应用程序. 2.网络协议有哪些? HTTP: ...

  8. 使用Java面向对象单词必备

    第一章 class   班级,用声明类 object     目标,整个程序集对大 static  静态的 final  不可更改的,用声明常量 private  私有的,用访问权限 public  ...

  9. 数字音频处理的瑞士军刀sox的音效算法以及用法

    SoX可以明确的写出需要的音频处理的效果,可以方便的重复使用,在目前的条件下是一个比较方便使用的项目.不过相信随着Audacity的发展,很有可能在未来可以逐渐替代SoX的功能. 对于SoX主要关心的 ...

  10. 超声波手势识别(STM32四路超声波获取)

    超声波手势识别在市场上已经有见实现,但研究其传感器发现并不是市场上随意可见的,如果暂且考虑成本,该如何入门实现简单的手势识别呢.聊天中老师给出一个很好的提议,就是固定四个超声波,分别为上下左右,然后进 ...