Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    A Service script question


    Ive written a service script to run my java application which runs it using java command and the only way that i can stop the service is to kill the java application using --> killall java, but since I may have other java apps running this command will kill all!
    Is there anyway I can kill the processes i started in start section of the script? since im a newbie in linux scripting any help would be appricieated!

    this is my current script -->

    # Source function library.
    . /etc/init.d/functions
    case "$1" in
    echo $"Starting Sipop"
    /usr/local/jdk1.5.0_03/bin/java -classpath /usr/local/sipop:/usr/local/sipop/asterisk-java-0.2.jar net.translumina.sipop.SipopServer &
    killall java
    echo $"Usage: $0 {start|stop}"
    exit 1
    exit $RETVAL

  2. #2
    have you tried:
    top (afterwards press k to kill) OR
    ps aux (to see the pid)
    Now what? You have Linux installed and running. The GUI is working fine, but you are getting tired of changing your desktop themes. You keep seeing this "terminal" thing. Don't worry, they'll show you what to do @
    <~ ~>

  3. #3
    I want to stop that process using --> "service sipop stop" command automatically, Im looking for a way to save the pid in the service script so when it runs the "stop" function, the script can automatically find and kill that pid ..., im looking for such a script...

    OR is there any way I can change the process name of java in the start script after -->
    /usr/local/jdk1.5.0_03/bin/java -classpath /usr/local/sipop:/usr/local/sipop/asterisk-java-0.2.jar net.translumina.sipop.SipopServer &

    so i can run killall "the_new_name_of_the_process" in the stop script...

    Quote Originally Posted by muha
    have you tried:
    top (afterwards press k to kill) OR
    ps aux (to see the pid)

  4. $spacer_open
  5. #4
    Linux User
    Join Date
    Aug 2005
    This is the solution: after your launch a process, the automatic variable $! contains the pid of the last command executed...

    So you'll start an application with:

    java <program> && echo $! > /var/tmp/ &
    So you'll stop the application with:

    kill `cat /var/tmp/app.tmp`
    When using Windows, have you ever told "Ehi... do your business?"
    Linux user #396597 (

  6. #5
    Thanks burnit, that script was what i exactly had been lookin for!

Posting Permissions

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