Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2010
    Posts
    16
    Rep Power
    0

    Exclamation Need help in quitting a unix process from java after a certain time

    Hi All ,

    I am executing a shell script through java .

    Runtime run=Runtime.getRuntime();
    Process proc=run.exec("/root/umdhanas/New/hello.sh");

    Now my requirement is i need to monitor from my java program as if the script execution takes more than 2 mins, i should kill that process from my java program. Not sure as how it can be done. Please help me on this.

  2. #2
    xerberuz is offline Member
    Join Date
    Apr 2010
    Posts
    8
    Rep Power
    0

    Default

    Use the ProcessBuilder instead of the runtime call.

    ProcessBuilder (Java 2 Platform SE 5.0)

    Edit: You can use the Process object to terminate the sup-process.
    Last edited by xerberuz; 11-09-2010 at 12:47 PM.

Similar Threads

  1. Replies: 3
    Last Post: 08-23-2011, 12:46 PM
  2. Run Unix commands from Java
    By yahyaaa in forum New To Java
    Replies: 13
    Last Post: 06-17-2010, 11:50 PM
  3. Need help with Process execution time display
    By murali18 in forum New To Java
    Replies: 5
    Last Post: 03-18-2010, 11:19 PM
  4. using java to login to unix
    By dowell in forum Advanced Java
    Replies: 4
    Last Post: 05-23-2008, 07:26 AM
  5. How can I set a time out on the loading process
    By paul in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 04:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •