The Holy Java

Building the right thing, building it right, fast

Fix Shell Script Run via SSH Hanging (Jenkins)

Posted by Jakub Holý on February 17, 2015

There is an important difference between running a script manually (ssh machine; machine$ ./ and running it via ssh (ssh machine < in the letter case the connection will not close when the script finishes but will stay open until stdout/stderr are closed or a timeout occurs. In Jenkins it will therefore seem as if the script hangs.

So if your shell scripts starts any background job, make sure to redirect all its output to somewhere:

nohup some-background-task &> /dev/null   # No space between & and > !

This has bitten me when trying to deploy an application from the Jenkins CI using SSH and a shell script.


Sorry, the comment form is closed at this time.

%d bloggers like this: