This discussion is archived
4 Replies Latest reply: Jul 8, 2010 4:41 PM by jschellSomeoneStoleMyAlias RSS

How to create an app that lists/monitors current batch (.cmd) jobs running

843798 Newbie
Currently Being Moderated
Hello,

Hoping someone can point me into the right direction/technology/approach.

The requirement is to create a status window/interface that
- lists available batch (.cmd) jobs
- ability to select a batch script to run
- gives a summary of currently running batches

Additional info: .cmd files call Essbase calculations that takes a while to process (10-20 minutes)

Because I'm a Java Developer, I've been asked to write a java app to do this. I'm not sure, that Java is the right technology. I'm not sure where to start so any help would be appreciated.

Thank you,
  • 1. Re: How to create an app that lists/monitors current batch (.cmd) jobs running
    843798 Newbie
    Currently Being Moderated
    - lists available batch (.cmd) jobs
    If you know where they are located in the file system then File.listFiles()
    - ability to select a batch script to run
    You can run it by creating java.lang.Process and keeping it somewhere. AFAIR you have to execute "cmd /c yourbatch.cmd" under Windows.
    - gives a summary of currently running batches
    As you keep all the Processes you have started, you can periodically check if a Process has ended (Process.exitValue()) .
    Remember also to "swallow" processes' output streams (Process.getOutputStream()) otherwise, the process will hang if it's output buffer gets filled.
    Reading the process output stream may be benefitial because you can display the process progress to the user (if any is printed at all).
  • 2. Re: How to create an app that lists/monitors current batch (.cmd) jobs running
    843798 Newbie
    Currently Being Moderated
    Thanks Adam. That is a really useful reply.

    When you say periodically check for if a Proces has ended. Do you mean having a Thread that wakes up once in a while to check?

    Also, I would think this has to be a stand-alone java app running on the server. The management insists on having a web-app. I'm not sure how a web application could be developed this way... maybe somehow with a servlet?

    thanks again
  • 3. Re: How to create an app that lists/monitors current batch (.cmd) jobs running
    843798 Newbie
    Currently Being Moderated
    When you say periodically check for if a Proces has ended. Do you mean having a Thread that wakes up once in a while to check?
    Yes, that's one possible solution. Alternatively you can spawn one Thread per Process, the thread runs the process and then hangs on Process.waitFor() ...
    Also, I would think this has to be a stand-alone java app running on the server. The management insists on having a web-app. I'm not sure how a web application could be developed this way... maybe somehow with a servlet?
    If you have never created a webapp then a lot of reading awaits you :). Anyway if you want to quickly and easily develop a web applicaiton, you may consider using such framework as GWT/Vaadin/Echo/etc, that make all the HTTP/HTML/Javascript related stuff "transparent" for the developer.
  • 4. Re: How to create an app that lists/monitors current batch (.cmd) jobs running
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    aneta737 wrote:
    Thanks Adam. That is a really useful reply.

    When you say periodically check for if a Proces has ended. Do you mean having a Thread that wakes up once in a while to check?

    Also, I would think this has to be a stand-alone java app running on the server. The management insists on having a web-app. I'm not sure how a web application could be developed this way... maybe somehow with a servlet?
    Something has to run on the server. At a minimum the batch job must be running. And to start a batch job the app that starts it must be running on the server as well.

    And a "web app" must come from a server as well. Although in that case it could be a different server (although that is probably pointless and adds difficulties.)

    That suggests that you must have a java server running on the server box. That does the management of the jobs. The "web app" part interacts with the server to report on progress.

    Common solutions to this problem is to use a JEE container such as jboss\tomcat to facilitate the server part. One advantage to those, versus writing your own, is that they are already set up to run independently. Downside is learning how to use them.