Pregunta

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?

¿Fue útil?

Solución

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 &

Otros consejos

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, use nohup 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 &
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top