What is corresponding Cron expression to fire in every X seconds, where X > 60? --转载

原文地址:http://stackoverflow.com/questions/2996280/what-is-corresponding-cron-expression-to-fire-in-every-x-seconds-where-x-60

Question:

I want my jobs to execute in every X seconds, there‘s one to one matching between job and X. Also during runtime there can be registered new jobs with their own intervals.

I‘ve tried to write cron expression for such scenarios, but in documentation there‘s written that value of seconds can‘t be more than 59. So cron expression like this: "0/63 * * * * ?" isn‘t valid.

At first sight solution of that problem seemed to be expression like this: "0/3 0/1 * * * ?", but it means completely different thing: trigger job in every three second of every minute.

Can you suggest what is the right solution (cron expression) for that? I know I could use just simple timers, but I‘ve to use cron jobs using Quartz.

answer:

The Quartz cron syntax is designed to express timing based on the standard 24 hour, 60 minute clock. It‘s not suitable for "every n seconds", where n can be any value. You‘re not going to able to do this with cron expressions.

If you need to do this with Quartz, you should use SimpleTrigger, not CronTrigger. You don‘t really have an option, unless you want to use a hugely complex collection of overlapping, artificially-deduced cron expressions.

碰到这个问题的时候,我陷入了误区,在stackoverflow上一看,明白自己掉坑里了。

时间: 2024-11-04 07:17:55

What is corresponding Cron expression to fire in every X seconds, where X > 60? --转载的相关文章

PHP Cron Expression Parser ( LARAVEL )

   The PHP cron expression parser can parse a CRON expression, determine if it is due to run, calculate the next run date of the expression, and calculate the previous run date of the expression. You can calculate dates far into the future or past by

Quartz.Net Cron Expression

正如标题所示,文章主要是围绕Quartz.Net作业调度框架话题展开的,内容出自博主学习官方Examples的学习心得与体会,文中难免会有错误之处,还请指出得以指教. 前面了解了一些基本触发器构造作业调度的基础例子,接下来本篇会学习到关于Cron表达式的触发器. PS:ICronTrigger触发器所轮询的将是无限重复轮询. 一,还是先来看一下代码 using System; using System.Collections.Generic; using System.Linq; using S

Cron Expression

Cron 指计划任务,用7个以空格分开的域(字符串)表示任务在约定的时间执行. 7个域分别代表如下含义: Seconds | Minutes | Hours | DayOfMonths | Month | DayOfWeek | Year[Optional] 每个域均可使用值 ",". "-" . "*". "/", 其他选值如下: Seconds: 有效值范围 [0 - 59] Minutes: 有效值范围 [0 - 59]

Core Expression

https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm A Cron Expressions Cron expressions are used to configure instances of CronTrigger, a subclass of org.quartz.Trigger. A cron expression is a string consisting of six or sev

task:scheduled cron 合法

task:scheduled org.springframework.scheduling.support.CronSequenceGenerator.parse /** * Parse the given pattern expression. */ private void parse(String expression) throws IllegalArgumentException { String[] fields = StringUtils.tokenizeToStringArray

Quartz:Cron Expressions

原文地址:http://www.quartz-scheduler.net/documentation/quartz-2.x/tutorial/crontrigger.html 注意: 位数可能是6位也可能是7位,最后1位的年可以省略. 第4位和第6位使用问号解决每月的那几天和每周的那几天的冲突问题.加了问号表示该位不起作用. Format A cron expression is a string comprised of 6 or 7 fields separated by white spa

THINKPHP的cron计划任务的实现

写一个cli的入口文件 cli.php <?php define('MODE_NAME', 'cli'); // 检测PHP环境 if(version_compare(PHP_VERSION,'5.3.0','<'))  die('require PHP > 5.3.0 !'); define('APP_DEBUG', true); // 定义应用目录 define('APP_PATH', __DIR__ . '/Application/'); // 引入ThinkPHP入口文件 req

cron表达式的解释

cron表达式是什么 首先cron是表示计划任务.其次Oracle官网这样解释cron表达式: Cron expressions are used to configure instances of CronTrigger, a subclass of org.quartz.Trigger. A cron expression is a string consisting of six or seven subexpressions (fields) that describe individu

spring cron 定时器

Spring Cron 表达式的格式如下: Cron expression is represented by six fields: second, minute, hour, day of month, month, day(s) of week 秒 分 时 日 月 星期 秒: 0-59 分: 0-59 时: 0-23 日: 1-31 月: 1-12 星期:1-7 (1-星期天, 2-星期一,3-星期二,4-星期三 ... ...) 特殊字符: * 表示任意值,如果放在 小时域 ,表示的就是