简体   繁体   中英

Cross-Platform Job Scheduling with Java

I have a java application (jar file) and I want to add some sort of scheduling option in it. This means that the application will offer users the ability to carry out a particular job automatically in intervals as defined by the users themselves. I was thinking of calling the scheduler from the command line (through Java code), such as using the 'AT' command for Windows and Anacron for UNIX-based systems.

My first part of the question is about the 'AT' command in Windows:

I have tried using the 'AT' command from the command line directly however I can't seem to get it to work. The job is listed as a scheduled task, however when the time elapses the task is not executed. (The task that I'm trying to run is a jar file which runs perfectly normal when I run it from the command line without the scheduling.) Would anyone be kind enough to point out anything that I might be doing wrong? The command I am supplying is as follows:

'AT XX:XX java -jar C:....\\xyz.jar' ,where XX:XX is the time that I want to run it at.

The second part of the question is about any other different implementations of such functions:

I am open for ideas, so if there is a different way of implementing such a function please do not hesitate to mention it. The implementation has to be cross-platform and if possible, free.

Really only an answer to the second part of your question, but you might want to take a look at Quartz Scheduler .

You can also potentially use a framework like Spring that supports Quartz to simplify and understand the usage further Quartz Scheduling with Spring .

您需要检查“任务计划程序”服务已启动,并将完整路径添加到java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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