Java Task / Cron environment

H

Horst Walter

I have to solve the following issues:

- I need to run Java programs at a certain time (cron-like).
- It's sometimes one program, sometimes multiple in parallel.
- These programs should each run in an individual JVM.
- After one program I might have to trigger other programs based on
the outcome.
- All these prg. are basically Java command line prgs.

Is there a free Java tool which I can use for this.
- Preferable if I can control this with RMI and / or a web interface
- It has be to "free"

Has somebody an idea or already solved a similar job.
Even if there is no "ready to use" prg around, maybe somebody has some
ideas what could be used as basis.

Thx
HW
 
M

Manavendra Gupta

- I need to run Java programs at a certain time (cron-like).
+ create a cron script, specifying the times and full path names of the
java class tasks that you want to run.
- It's sometimes one program, sometimes multiple in parallel.
+ specify as many tasks as you want. for parallel tasks, specify same
times (or keep them into a batch file and give that to cron).
- These programs should each run in an individual JVM.
+ no problem. ensure you specify the full path name to JVM and the java
class - a new process+environment will be created for each.
- After one program I might have to trigger other programs based on
the outcome.
+ Use pipes ( | ) to pipe the output of one to the input of other.
- All these prg. are basically Java command line prgs.

Dont know if there is such a program available, but if you are unix, then
cron can be used IMO
 
H

Horst Walter

Thanks for the answer. Yes I could do this with CRON / Linux commands.
But for me this is not the right approach - for several reasons:

One is - I did not mention this before - I have to run this on
Win/Linux/Sun. Second is, I am looking for a litte more sophisticated
solution. I am aware, there is nothing wrong about shell programming.
Everything can be done, there are even solutions which are platform
independent (e.g. Perl).

But my intention is to do it in Java, especially with the background
I'd like to incorporate this in our J2EE Web environment.

Best regards
KB
 
G

Gordon Beaton

Thanks for the answer. Yes I could do this with CRON / Linux
commands. But for me this is not the right approach - for several
reasons:

One is - I did not mention this before - I have to run this on
Win/Linux/Sun. Second is, I am looking for a litte more
sophisticated solution. I am aware, there is nothing wrong about
shell programming. Everything can be done, there are even solutions
which are platform independent (e.g. Perl).

But my intention is to do it in Java, especially with the background
I'd like to incorporate this in our J2EE Web environment.

He's not suggesting that you abandon Java in favour of shell
scripting. He is suggesting that you use cron to *schedule* your Java
programs.

Cron is part of every Linux as well as "Sun" (do you mean Solaris? I
run Linux on my Suns), and I am certain that there is a native windows
equivalent or at least a windows version of cron.

There is no need to reinvent the wheel.

/gordon
 
M

Manavendra Gupta

Horst Walter said:
Thanks for the answer. No worries
Yes I could do this with CRON / Linux commands.
But for me this is not the right approach - for several reasons:

One is - I did not mention this before - I have to run this on
Win/Linux/Sun. Second is, I am looking for a litte more sophisticated
solution. I am aware, there is nothing wrong about shell programming.
Everything can be done, there are even solutions which are platform
independent (e.g. Perl).
IMO, for what you wish to do, should best be a combination of probably
OS-specific stuff (cron on windows and the similar MSTask (?) for Win,etc)
or platform independent (Perl, as you said) and java. The core process
should be in your java classes, which shall be invoked by a crontab script.
But my intention is to do it in Java, especially with the background
I'd like to incorporate this in our J2EE Web environment.

Ahh, now we are talking. Take a look at the TimerService, which allows you
to schedule a timed notification to occur at a specific time, after a
duration of time, or at timed intervals. When the timer goes off, the EJB
Container calls the timeout() method (i'm not sure if thats the correct
name, you'd have to lookup), which should contain the business logic. So,
following is what you'd need to do the J2EE way:

1. Create a DB model where you storer your timers, events and associated
process. This should also store the where the output of each process should
go and at least some description of each process
2. A TimerService that understand this DB model and forks each process on a
specific timeout, as modeled
3. A web interface to your database for your CRUD operations

HTH
Manav
 
N

news.neti.ee

check out Quartz:

"An enterprise-class job scheduler for integration with stand-alone java
applications and full-scale J2EE applications. Advanced features include
clustering and participation in container managed transactions."

http://sourceforge.net/projects/quartz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top