获取“最后跑步时间”是时候进行石英工作了
是否有一个API可以确定quartz作业的最后执行时间。
谢谢, 桑迪亚
Is there an API to determine the last execution time of a quartz job.
Thanks,
Sandhya
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
严格来说,作业没有触发时间,而触发器有。触发器有 getPreviousFireTime()。请参阅http://www.quartz-scheduler.org/api/2.2.0/org/quartz/Trigger.html#getPreviousFireTime%28%29" quartz-scheduler.org/api/2.2.0/org/quartz/Trigger.html#getPreviousFireTime%28%29
如果您的作业有多个触发器,您可以检索所有触发器并检查它们的触发时间。请参阅食谱示例 http://www.quartz-scheduler.org/docs/食谱/index.html
Strictly speaking, a Job doesn't have a fire time, a Trigger does. And Trigger has getPreviousFireTime(). See http://www.quartz-scheduler.org/api/2.2.0/org/quartz/Trigger.html#getPreviousFireTime%28%29
If your Job has multiple triggers, you can retrieve them all and examine their fire times. See the cookbook examples at http://www.quartz-scheduler.org/docs/cookbook/index.html
假设您的作业所具有的重写
executeInternal
或execute
方法中需要“上次执行时间”。它作为参数获取的 JobExecutionContext 已经提供了方法getPreviousFireTime()
这是最近触发并执行作业的触发器的上一个触发时间。With the assumption that the "last execution time" is needed inside the overriden
executeInternal
orexecute
method that your job has. TheJobExecutionContext
that it gets as a parameter already provides the methodgetPreviousFireTime()
which is the Previous Fire Time of the most recent trigger that fired and executed your Job.