石英五金钟
我在我的项目中使用 quartz 并有一个 cron 作业。 我将触发器 (CronTrigger) 作为运行参数与电脑的硬件时钟一致。有什么想法如何告诉工作查看软件时钟吗?
例如,我有一个运行了一年的作业,它恰好在晚上 10 点运行,有一天我们切换到夏季时间,我希望 cron 作业能够自动更新。
罗马
I am using quartz in my project and have one cron job.
The cron expression I give the trigger (CronTrigger) as the running parameter is alighnt with the pc's hardware clock. Any ideas how to tell the job to look at the software clock instead ?
For instance I have a Job running for a year , and the it runs exactly at 10pm, and someday we switch to summer time , I would like the cron job to be automatically updated.
Roman
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您所说的“夏令时”是指更改为 Daylight_ saving_time 吗?
该情况将自动处理。
您唯一需要注意的是在实际轮班期间安排的工作。
在前移中,时间从
凌晨 1 点(标准)
到凌晨 2 点(标准)
,再到凌晨 1 点(夏令时)
。计划在凌晨 1 点到 2 点之间运行的作业需要确保它们不会运行两次。
向后移动可能会产生相反的效果。时间从
凌晨 1 点(夏令时)
到凌晨 2 点(夏令时)
再到凌晨 3 点(标准)
。根据 Quartz 的实现方式,它可以跳过该时间间隔内的作业,也可以在轮班后运行该时间间隔内的所有作业。如果这是一项绝对必须运行的作业,请将其安排在轮班窗口之外(轮班时间+/- 1 小时)。
By "summer time" you mean a change to Daylight_saving_time?
That case will be handled automatically.
The only thing you need to be careful of is jobs scheduled during the actual shift itself.
In the forward shift the time goes from
1am (std)
to2am (std)
to1am (dst)
.Jobs scheduled to run between 1am and 2am need to make sure they do not run twice.
The shift back may have the reverse effect. The time goes from
1am (dst)
to2am (dst)
to3am (std)
. Depending on how Quartz has implemented it, it can either skip the jobs in the interval, or run all the jobs in the interval after the shift.If it's a job that absolutely must run, schedule it outside the shift window (shift time +/- 1 hour).
简单,始终使用UTC作为系统时间(和时区) 在服务器上。
我是认真的,这涉及夏令时规则等问题,有助于确保时间近*单调增加(即时间不会向后“跳跃”,打破了依赖时间的软件的许多假设),以及服务器和/或跨时区的用户(即地理上分布的计算机和/或用户)。
*)对于这种情况,我将忽略闰秒。
由于这似乎是计算机系统和操作系统相关工具(即
cron
)的问题,我认为这个问题不适合 StackOverflow.com 请考虑将其移至 ServerFault.comSimple, always use UTC for system time (and time zone) on servers.
I'm serious, this deals with issues like Daylight Saving rules, helps to ensure a near* monotonic increase in time (i.e. time doesn't "jump" backwards, breaking many assumptions for time-dependent software), and for servers and/or users across time-zones (i.e. geographically distributed computers and/or users).
*) I'll ignore leap seconds for this situation.
Since this appears to an issue with the computer system, and OS related tools (i.e.
cron
), I don't think this question is suitable for StackOverflow.com please consider moving it to ServerFault.com