Tuesday, April 2, 2013

Run background java process from Jenkins

Jenkins is using mechanism to detect spawned processes and kill them after finishing job, so if you will just start such ad-hoc background daemon process, Jenkins will kill it with warning:

Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information

Fortunately, there is easy hack to tell Jenkins ignore such process, just create fake BUILD_ID and start your application, for example, this can be entered into Execute shell build step:

BUILD_ID=dontKillMe nohup java -jar test.jar &

Warning is still there, but process should be fine and running. There is more about it here.


  1. Thanks a lot! I spent 1 day for this problem.

  2. Where i need to give this command, at Jenkins server or client...
    i spent almost one day so far but still no luck.. please give quick answer...

  3. give in batch file ex: set BUILD_ID=dontKillMe nohup java -jar test.jar &
    its worked...

  4. This comment has been removed by the author.

  5. if you put nohup java -jar test.jar & in another shell script, call start_up.sh, and execute shell in jenkins: BUILD_ID=dontKillMe nohup start_up.sh &. It DON NOT work! I don't know why and wonder how to fix it..

  6. for anyone else, I had to put the dontkillme line ABOVE the background task in windows ie :

    set BUILD_ID=dontKillMe
    @start /b cmd /c bundle exec thin start

    this problem has wasted me nearly an entire day today :(

  7. Administrations, for example, background checks are more open. Through this article, I am will confer to you the best background check organization accessible on the net.best background investigation services