java调度器还有其他方法比Quartz更容易理解吗?

发布于 2024-10-20 19:19:04 字数 219 浏览 5 评论 0原文

我创建了一个小型 java 程序,我想每天下午 1 点启动它。 我可以添加它 Windows 任务计划器,它工作得很好,但我想用 java 来做。

java的定时器任务好像不太好。

我听说过 Quartz,当我尝试它们时,它对我来说似乎很复杂,或者我找不到简单的示例或教程。

任何人都可以比 Quartz 网站更容易地了解一些好的教程或示例代码。 或者将我重定向到其他网站。

I've created a small java program and I want to launch it everyday at 1 o'clock.
I can add it windows task plannifier and it works very well but I want to do it with java.

The java timer task seems to be not good.

I heard about Quartz and when I try their it seems to be complicated for me or I don't find the simple example or tutorial.

Can anyone know some good tutorial or example code easier than the Quartz's site.
Or redirect me to some other site.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

奢华的一滴泪 2024-10-27 19:19:04

Quartz 和内置的 Timer 类都不是为了启动整个应用程序而构建的。它们被构建为只要您的应用程序正在运行,就可以根据某个时间表运行某些指定的任务。

要在指定时间实际启动您的应用程序,需要外部资源(除非您希望应用程序始终运行并且只经常执行某些活动)。

为此,Windows 任务计划程序就足够了。

Both Quartz and the built in Timer class are not built to start your whole application. They are built to run some specified tasks according to some schedule as long as your application is running.

To actually start your application at a specified time, an external resource will be necessary (unless you want your application to run at all times and only do some activity ever so often).

For that purpose the Windows Task Scheduler is sufficient.

财迷小姐 2024-10-27 19:19:04

Quartz

Quartz 是一个功能齐全的开源作业调度服务,可以与几乎可以支持任何 Java EE 或 Java SE 应用程序。

基本术语是(从非常基本的角度来看):

调度程序:您可以将其视为核心容器或石英基础的东西。

Job:你可以认为这是我们需要做的任务,简单的java类

触发器:让Job在调度程序上运行的东西,有两种类型的触发器使用quartz

  1. Simple Trigger(您可以配置执行之间的延迟、首次执行的延迟......以及许多此类参数)
  2. Cron-Trigger :在这里您可以使用 cron 表达式配置触发器。

另请参阅

Quartz

Quartz is a full-featured, open source job scheduling service that can be integrated with, or used along side virtually any Java EE or Java SE application.

The basic terminology are (at very basic view):

Scheduler : You can think of this as the core container or something that is the base of quartz.

Job : You can think this as the task we need to do , out simple java Class

Trigger : Something that will make Job to run on scheduler, there are two types of trigger with quartz

  1. Simple Trigger (you can configure it with delay between execution, delay for first execution . . and many such params)
  2. Cron-Trigger : Here you can configure trigger with cron expression.

Also See

偷得浮生 2024-10-27 19:19:04
small java program and I want to launch it everyday at 1 o'clock
  1. unix 中的 cronjob

    每天在特定时间安排作业

cron 的基本用法是在特定时间执行作业
时间如下所示。这将执行 sample_java_program
每天凌晨 1 点。

30 01 * * * java /home/suresh/sample_java_program

    * 30 – 30th Minute
    * 01 – 01 AM
    * * – every Day
    * * – every Month 
    * * – Every day of the week
  1. 在 Windows 中安排 此链接可能对您有帮助。
small java program and I want to launch it everyday at 1 o'clock
  1. cronjob in unix

    Scheduling a Job For a Specific Time Every Day

The basic usage of cron is to execute a job in a specific
time as shown below.This will execute the sample_java_program
everyday at 1am.

30 01 * * * java /home/suresh/sample_java_program

    * 30 – 30th Minute
    * 01 – 01 AM
    * * – every Day
    * * – every Month 
    * * – Every day of the week
  1. Scheduling in windows this link might help u .
淡笑忘祈一世凡恋 2024-10-27 19:19:04

cron4j 是另一个

cron4j is another one

茶底世界 2024-10-27 19:19:04

当你说:
Quartz 和内置的 Timer 类都不是为了启动整个应用程序而构建的。

所以我永远无法使用 Quartz 或 Timer 启动我的整个 java 程序。
它只在我的 prg 运行时启动一些特定的任务?

那么保留 Windows 任务计划程序会更好吗?
好的,谢谢

When you say:
Both Quartz and the built in Timer class are not built to start your whole application.

So i could never launch my whole java program with Quartz or Timer.
it only launches some speicfic task while my prg is running?

so it's better to keep Windows task Scheduler?
ok thank you

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