Search code examples
pythonshelljenkinsbackground-process

Jenkins run a script in background


How can I trigger a script say A (in python) using Jenkins such that a shell script triggered internally from script A keeps running in background even after Jenkins build is done.

Right now, what I observe is that as soon as Jenkins job ends, it kills the background shell script too. However, running the python script manually on the terminal is fine.

Is there a way that I can skip killing that background shell script from Jenkins?


Solution

  • After searching for the solution, I came across this link "Spawning process from build"

    https://wiki.jenkins.io/display/JENKINS/Spawning+processes+from+build

    Adding below command to build step helped:

    BUILD_ID=dontKillMe nohup shell_script_to_run.sh &