Hangfire定时任务设置CronExpression表达式
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.
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 */20
in 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表达式的更多相关文章
- Quartz在Spring中动态设置cronExpression (spring设置动态定时任务)
什么是动态定时任务:是由客户制定生成的,服务端只知道该去执行什么任务,但任务的定时是不确定的(是由客户制定). 这样总不能修改配置文件每定制个定时任务就增加一个trigger吧,即便允许客户 ...
- spring框架的定时任务cronExpression表达式详解
附:cronExpression表达式解释: 0 0 12 * * ?---------------在每天中午12:00触发 0 15 10 ? * *---------------每天上午10:15 ...
- 关于cronExpression表达式
spring 定时任务设置,关于cronExpression表达式: 字段 允许值 允许的特殊字符 秒 0-59 , - * / 分 0-59 , - * / 小时 0-23 , - * / 日期 1 ...
- Quartz.net 定时任务之Cron表达式
一.cron表达式简单介绍和下载 1.在上一篇博客"Quartz.net 定时任务之简单任务"中,我简单介绍了quartz的使用,而这篇博客我将介绍cron的具体使用(不足之处望大 ...
- Quartz在Spring中动态设置cronExpression
什么是动态定时任务:是由客户制定生成的,服务端只知道该去执行什么任务,但任务的定时是不确定的(是由客户制定). 这样总不能修改配置文件每定制个定时任务就增加一个trigger吧,即便允许客户修改配置文 ...
- JDK、Spring、Quartz等几种不同定时器的用法,以及cronExpression表达式定义
referenc:https://blog.csdn.net/clementad/article/details/42042111 下面介绍几种常用的定时器及其实现方法: 第一种:Timer和Time ...
- 【Hadoop离线基础总结】oozie定时任务设置
目录 简介 概述 oozie定时任务设置 1.拷贝定时任务的调度模板 拷贝hello.sh脚本 3.修改配置文件 4.上传到hdfs对应路径 5.运行定时任务 简介 概述 在oozie当中,主要是通过 ...
- Quartz中时间表达式的设置-----corn表达式
Quartz中时间表达式的设置-----corn表达式 时间格式: <!-- s m h d m w(?) y(?) -->, 分别相应: 秒>分>小时>日>月 ...
- Quartz中时间表达式的设置-----corn表达式 (转)(http://www.cnblogs.com/GarfieldTom/p/3746290.html)
Quartz中时间表达式的设置-----corn表达式 (注:这是让我看比较明白的一个博文,但是抱歉,没有找到原作者,如有侵犯,请告知) 时间格式: <!-- s m h d m w(?) y( ...
随机推荐
- Vue.js——快速入门
Vue.js是当下很火的一个JavaScript MVVM库,它是以数据驱动和组件化的思想构建的.相比于Angular.js,Vue.js提供了更加简洁.更易于理解的API,使得我们能够快速地上手并使 ...
- Android中系统键盘的自动弹出、隐藏和显示
一.需求 在开发Android app过程中经常用到EditText,需要在界面加载完成后自动弹出系统键盘,更希望可以控制键盘的隐藏和显示,本文介绍其实现方法. 二.系统键盘的自动弹出 @Overri ...
- [转] An Introduction to Mutual SSL Authentication
1. Introduction Mutual SSL authentication or certificate based mutual authentication refers to two p ...
- Windows反复重启的可能的解决办法
Windows反复重启,原因很多,下面提供两个可能的解决办法: 1. 查看BIOS中关于SATA的设置,一般只有两种PCIE和IDE,调整成另外一个试试: 2. 查看BIOS的启动模式,如果是UEFI ...
- 微信小程序中如何使用WebSocket实现长连接(含完整源码)
本文由腾讯云技术团队原创,感谢作者的分享. 1.前言 微信小程序提供了一套在微信上运行小程序的解决方案,有比较完整的框架.组件以及 API,在这个平台上面的想象空间很大.腾讯云研究了一番之后,发现 ...
- JSON Web Token(JWT)原理和用法介绍
JSON Web Token(JWT)是目前最流行的跨域身份验证解决方案.今天给大家介绍一下JWT的原理和用法. 官网地址:https://jwt.io/ 一.跨域身份验证 Internet服务无法与 ...
- JavaScript 基础排序的实现(一)
作为一个有追求的前端,忙里偷闲(闲得发慌)地复习了一下基础的排序算法,以此文留念. 本篇主要记录O(n²)复杂度的基础算法O(nlogn)的算法将在下次有空(闲得发慌)时更新 在记录时发现Es6语法中 ...
- [Postman]Cookies(12)
Postman的本机应用程序提供 MANAGE COOKIES 模式,允许您编辑与每个域关联的Cookie. 前往cookie经理 要打开MANAGE COOKIES模式,请单击“ 发送”按钮下的 ...
- Java回调机制总结
调用和回调机制 在一个应用系统中, 无论使用何种语言开发, 必然存在模块之间的调用, 调用的方式分为几种: 1.同步调用 同步调用是最基本并且最简单的一种调用方式, 类A的方法a()调用类B的方法b( ...
- sql的转义字符单引号
在SQL中,我们都知道单引号 ' 表示字符串的开始和结束符号,如: select * from students where name = '小明'; 但如果字符串里面有单引号时,应该怎么查询呢? 这 ...