如何每天从 Java 运行任务? [英] How to run a task daily from Java?

查看:16
本文介绍了如何每天从 Java 运行任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 java.util.Timer 每天在指定时间(比如上午 11:00)运行任务?我使用的是 JDK 1.4.2,我知道它很旧,但这正是项目所需要的.

How can I run a task daily at a specified time (say 11:00 am) using java.util.Timer? I'm using JDK 1.4.2, I know it's old, but it's what the project requires.

推荐答案

Quartz 是在 Java 环境中调度进程的最著名的解决方案,但您有很多选择.检查此列表:

Quartz is the most well known solution to schedule processes in Java environments, but you have a lot of options. Check this list:

Quartz 是一个可以集成的开源作业调度系统与几乎任何 J2EE 或 J2SE 应用程序一起使用或与任何 J2EE 或 J2SE 应用程序一起使用.Quartz 可用于创建简单或复杂的时间表.

Quartz is an open source job scheduling system that can be integrated with, or used along side virtually any J2EE or J2SE application. Quartz can be used to create simple or complex schedules.

Jcrontab 旨在与任何项目进行扩展和集成.读取并存储要在文件、数据库或 EJB 中执行的任务,并提供 Web UI 和基本的 Swing GUI.

Jcrontab is designed to be extended and integrated with any project. Reads and stores the tasks to execute in a file, a database or an EJB and provides a web UI and a basic swing GUI.

Essiembre J2EE Scheduler 是一种用于 J2EE 应用程序的简单任务调度机制.这个库可以被认为是标准 Java API 中 Timer 和 TimerTask 类的包装器.要执行的任务及其频率的配置是基于 XML 的.

Essiembre J2EE Scheduler is a simple task scheduling mechanism for J2EE applications. This library can be considered a wrapper around the Timer and TimerTask classes found in the standard Java API. Configuration for tasks to be executed and their frequency is XML-based.

cron4j 是 Java 2 平台的调度程序,非常类似于 UNIX cron 守护进程.

cron4j is a scheduler for the Java 2 platform which is very similar to the UNIX cron daemon.

Oddjob 的目标是为将企业的关键业务流程联系在一起的所有批处理文件和 cron 作业提供某种顺序和可见性.

Oddjob's goal is to provide some order and visibility to all the batch files and cron jobs that tie an enterprise's critical business processes together.

Fulcrum Scheduler 提供调度服务.它基于 Turbine 提供的 TurbineScheduler,但所有旧的东西都已被删除.目前只完成了非持久性调度程序.它从组件配置 xml 文件加载计划作业.

Fulcrum Scheduler provides a scheduler service. It is based on the TurbineScheduler provided with Turbine, but all older stuff has been removed. Currently ONLY the non persistent Scheduler is done. It loads scheduled jobs from the component config xml file.

Gos4j -面向目标的 Java 调度 - 是一种根据目标组织处理优先级.

Gos4j -Goal Oriented Scheduling for Java- is a way of organising processing priorities based on goals.

Job Scheduler 是一个像恶魔一样运行的批处理程序,并且可以使用图形用户界面进行控制.Job Scheduler 对计划的程序、脚本以及任务处理的时间和频率使用 XML 配置.有一个 API 可用于控制事件并记录到您的作业.

Job Scheduler is a batch program operating as a demon, and can be controlled using a graphical user interface. The Job Scheduler uses an XML configuration for the scheduled programs, scripts and for the timing and frequency of task processing. An API is available that hands control of events and logging to your jobs.

JDRing 是一个轻量级的 Java 调度库,它简单易用小,但仍然支持在指定的时间间隔响铃警报,作为一次性事件,或具有完整的类似 cron 控制的复杂时间表.

JDRing is a lightweight Java scheduling library that is simple and small, but still supports ringing alarms at specified intervals, as one-time events, or on complex schedules with full cron-like control.

jBatchEngine 是用 Java 编写的批处理作业假脱机程序.与 Cron 等时间驱动的调度程序相比,jBatchEngine 是事件驱动的.

jBatchEngine is a batch job spooler written in Java. In constrast to time driven schedulers like Cron, jBatchEngine is event driven.

MyBatchFramework 是一个开源轻量级框架,旨在在 Java 语言中创建轻松健壮且易于管理的批处理程序.

MyBatchFramework is an open-source lightweight framework designed to create easily robust and manageable batch programs into the Java language.

Super with SuperScheduler 和 SuperWatchdog 是一个 Java 作业调度器,具有丰富的所有应用程序的 GUI.它是平台中立的.尤其适合作为 Linux 和 Solaris 的作业调度程序.它提供了 Microsoft Windows 调度程序的一组超级功能.它提供事件触发的调度.它可以在分布式环境中调度任务.任务将在网络中的所有机器中执行一次且仅执行一次.所有任务都是假期可调的.即使每个作业都是 STANDBY 作业,历史记录也将是重要任务的良好踪迹.支持国际化.

Super with SuperScheduler and SuperWatchdog is a Java job scheduler with rich GUI for all applications. It is platform neutral. Especially good to be a job scheduler for Linux and Solaris. It provides a super set of functionalities of the Scheduler of Microsoft Windows. It provides event-triggered scheduling. It can schedule tasks in a distributed environment. A task will be executed once and only once among all machines in the network. All tasks are holiday adjustable. Even every job is a STANDBY job, the history will be a good trace for important tasks. It supports Internationalization.

来源:Java 中的开源作业调度程序

这篇关于如何每天从 Java 运行任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆