安排两个固定速率任务
你好: 在我的应用程序中,我必须将 tomcat 日志导出到数据库。
所以我尝试启动两个schedulFixedDate任务:
1)每天00:05:00,导出最近30天的数据(不包括今天(当天)),所有这些数据都放在一个表中。这是第一个计划任务
2)首先删除“log_today”表中的所有数据,然后将当天的日志逐小时导出到“log_today”表,在01:00/02:00/03:00/...这是另一个计划任务;
我的问题是这两个任务应该与另一个任务分开吗?或者他们应该按某种命令执行?
Hi:
In my application,I have to export tomcat log to database.
So I tried to start two schedulFixedDate task:
1)at 00:05:00 of everyday,export data of nearest 30 days(exclude today(current day)),all these data are put in one table.This is the first schedule task
2)first remove all the data in the "log_today" table,then export log of current day to "log_today" table hour by hour,at 01:00/02:00/03:00/... this is another schedule task;
My question is should the two task be separated with the other? or they should executed by some order?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取决于您的用例。
如果您需要任务 1 在任务 2 之前完成,则在固定时间/日期进行安排将不起作用,因为您无法确定任务 1 是否已完成。因此,在这种情况下,将它们作为单个计划运行,并在任务 2 之后立即执行任务 2 是有意义的。
如果任务 2 不依赖于任务 1,则将它们作为两个固定计划,因为这样更清晰,因此更容易维护。
Depends on your use case.
If you need task 1 to finish before task 2, then scheduling at a fixed time/date won't work, because you cannot be sure Task 1 completed. So, in this case it would make sense to run them as a single schedule, and perform task 2 immediately after task 2.
If task 2 does not rely on task 1, then put them as two fixed schedules, as it is clearer and therefore easier to maintain.