Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

schedule job in java

 
maheshk lala
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends ,

I want a java schedule program that runs every hour . It should search for in a directory for the latest files received in a hour and should read those files for every one hour . its a very urgent and your help is highly appreciated .
Using java.util.Timer etc.


Thanks for your help in advance .

Bye
MAHESH
========
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess Threads should work.
Or google for schedulers and run the job each and every hour with the help of scheduler.
[ July 08, 2005: Message edited by: Srinivasa Raghavan ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What operating system are you running? If you are running Linux, usually you use cron to schedule jobs like this. You can write your program in Java without any of the scheduling logic. The cron daemon will run your program at the specified times. Check the man pages for more details or visit our Linux/Unix forum.

However, I'm willing to bet you are using Windows instead. As Srinivasa mentioned above, you can probably google for a scheduler for Windows that works similarly to cron.

Layne
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can make your java program run forever and schedule the directory scans within the program. See Timer.
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want a pure Java implementation, then AFAIK your best bet is the Quartz scheduler. Depending on your requirements, this may be better than using Cron or a similar platform-specific method.

Quartz has all sorts of features for handling clusters of applications too. I'm not familiar with it beyond the basics, though.

[Edit - oops, I see the requirement is 'program that runs every hour', not
'job within program that runs every hour'. Still, I'll leave this post as it stands.]

-Tim
[ July 08, 2005: Message edited by: Tim West ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic