I have an upstart script in /etc/init/myexample.conf. This job basically runs a java jar file. Normally, I can start and stop this using sudo start myexample and sudo stop myexample.

I changed the jar file and introduced an error that caused the jar to crash. After starting the jar with sudo start myexample, I see the errors in my log file.

Now I would like to stop the upstart job and replace the jar file with a working one again. I have seen two scenarios:

  1. sudo stop myexample hangs indefinitely (at least 10 minutes). I also cannot start the job again with sudo start myexample, I receive the error start: Job is already running: myexample.

  2. sudo start myexample hangs indefinitely, and sudo stop myexample gives stop: Job has already been stopped: myexample.

I can also run the jar manually from the command line.

pgrep -lf myexample and pgrep -l myexample return nothing. pgrep -l java shows other java processes that are running, but not the failed one corresponding to myexample. Upstart thinks the process is running, but it is not.

How can I get the upstart job running again, without a reboot?


description "myexample"  

start on runlevel [2345]  
stop on shutdown  

respawn limit 3 120

expect daemon

setuid exampleuser

    chdir /home/exampleuser/ 
    java -jar /home/exampleuser/example.jar
end script

Kill the process.

You can kill the process (if running) by:

pkill <process_name>


killall <process_name>

This will match the process name only, if you want to match the whole command line, use (with extreme care):

pkill -f <part_of_the_command>

So in you case:

sudo pkill myexample

should do.

You can be sure beforehand, by running:

pgrep -l myexample

to check the process ID to make sure no other process coincides with the name.

On a different note, after finding the PID with pgrep -l myexample, you can kill the process with kill too:

kill PID
  • pgrep -l myexample returns nothing. pgrep -l java shows the java processes that have been started by running upstart jobs, but does not have a corresponding entry for myexample, the upstart job that failed. – mattm Mar 6 '16 at 4:21
  • @mattm That means the process is not running.. – heemayl Mar 6 '16 at 4:21
  • @mattm Edit your question and the upstart script you are talking about.. – heemayl Mar 6 '16 at 4:26
  • @mattm Yes..also whats the output of pgrep -lf myexample ? – heemayl Mar 6 '16 at 4:34
  • I updated the question with script. Also pgrep -lf myexample shows nothing. – mattm Mar 8 '16 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.