Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a script that calls a subscript and attempts to release/disown this script so that Jenkins calling the script can complete successfully. It seems to release the script on the command line, so I can log out or execute other scripts when on the command line (SSH), but Jenkins hangs waiting for the released script to finish. Is there a way around it?

super.sh

#!/bin/bash

/home/oracle/example/subscr.sh>temp-log.log</dev/null&
disown -h

echo "Done"
exit 0

subscr.sh

#!/bin/bash

while [ false ]; do
  echo "Still Working"
  sleep "5s"
done

When doing this, Jenkins just hangs endlessly until I kill the subscr execution.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

There are two ways I could think of to do this.

nohup

The command nohup will run a subcommand completely detached from your terminal, and send its output to a file:

$ nohup ls
appending output to nohup.out
$ cat nohup.out 
20111118153620
nohup.out

GNU screen

GNU screen can serve the same function in this context, of running a command with the output sent elsewhere. It also has the bonus feature of being able to reattach to the stdin and stdout of the process later on without restarting it if necessary. (It's hard to demo screen in a text buffer.)

share|improve this answer
    
Thanks, this seems to be an issue with the wrapper tha executes Jenkins scripts. I was able to fix this particular need by nohup from the ssh command. I've tested the above and it does work when calling directly from ssh –  Jeff Ancel Dec 20 '11 at 15:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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