0

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.

Jeff Ancel
  • 135
  • 2
  • 6

1 Answers1

2

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.)

Handyman5
  • 5,257
  • 26
  • 30
  • 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