简体   繁体   English

如何使特定的计划作业从启动时开始运行?

[英]How to make a specific scheduling job running from the time it is started?

I need to schedule a task that will perform the task at the given time by user. 我需要安排一个任务,该任务将由用户在给定的时间执行。 But this scheduling I need to run whether the application is running or not. 但是无论我是否正在运行该计划,我都需要运行。 So how could I specify the scheduling using quartz? 那么如何使用石英来指定排程呢?

I am writing the code for the situation in servlet and then from where I need to run that servlet I am bit confused about it, because if I would use the load-on-startup it will call servlet every time the application is loaded so it will cause the job detail to be duplicated in data tables. 我正在用servlet编写这种情况的代码,然后从需要运行该servlet的地方开始对此感到困惑,因为如果我使用启动时加载功能,则它将在每次加载应用程序时调用servlet,因此将导致作业详细信息在数据表中重复。 And the scheduling will stop when user will logout the session. 当用户注销会话时,计划将停止。 But I want the scheduling to be running till the tomcat is running. 但是我希望调度在tomcat运行之前一直运行。

Any help is appreciated. 任何帮助表示赞赏。 Thanks in advance. 提前致谢。

To avoid duplication of the job in the database you can write your code to first check for the job before scheduling, or to first delete the job (whether or not it exists) before scheduling. 为避免作业在数据库中重复,您可以编写代码以在计划之前首先检查该作业,或者在计划之前首先删除该作业(无论是否存在)。

In 2.x API there is a checkExists() set of methods. 在2.x API中,有一组checkExists()方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM