安排两个固定速率任务

发布于 2024-10-08 10:01:08 字数 284 浏览 0 评论 0原文

你好: 在我的应用程序中,我必须将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦晓ヶ微光ヅ倾城 2024-10-15 10:01:08

取决于您的用例。

如果您需要任务 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文