title: Jenkins job to kill process (Tomcat) over ssh
body: <p>I am using a Jenkins job to run a few simple shell commands (over ssh, via the Jenkins SSH Plugin); the commands are supposed to shut down a running Tomcat server: </p>
  
  <pre><code>sudo /opt/tomcat/bin/catalina.sh stop
  ps xu | awk '/[t]omcat/{print $2}' | xargs -r kill -9
  </code></pre>
  
  <p>The job executes fine and does terminate the Tomcat, but unfortunately it also fails; the full output is: </p>
  
  <pre><code>[SSH] executing pre build script:
  
  sudo /opt/tomcat/bin/catalina.sh stop
  ps xu | awk '/[t]omcat/{print $2}' | xargs kill -9
  [SSH] exit-status: -1
  Finished: FAILURE
  </code></pre>
  
  <p>Any idea why the exit code of the command if -1? I have tried several variations without any luck. </p>
  
  <p>Thanks. </p>