Reputation: 1078
I have a bash script that I am calling from a build step in Jenkins. Within this bash script is a nohup command for calling a different script in the background, such as:
#!/bin/bash
nohup otherScript.sh &
After the build step completes I go to the path where the nohup.out should have been created, but there is nothing there. Any ideas on what is going on?
Upvotes: 1
Views: 6772
Reputation: 200293
Quoting from man nohup
:
If standard input is a terminal, redirect it from /dev/null. If standard output is a terminal, append output to
nohup.out
if possible,$HOME/nohup.out
otherwise. If standard error is a terminal, redirect it to standard output. To save output to FILE, usenohup COMMAND > FILE
.
Running the command from Jenkins probably means that STDOUT
is not a terminal, thus nohup.out
is not created. As gareth_bowles already suggested, you should redirect the output to a file with a defined path:
nohup script.sh >/path/to/output.log 2>&1 &
Upvotes: 3
Reputation: 21130
You should make sure that the output goes into your build's workspace. This will avoid permission problems with other directories.
nohup otherScript.sh > $WORKSPACE/scriptOutput.txt 2>&1 &
Upvotes: 6