title: How to run a command in background using ssh and detach the session
body: <p>I'm currently trying to ssh into a remote machine and run a script, then leave the node with the script running. Below is my script. However, when it runs, the script is successfully run on the machine but ssh session hangs. What's the problem?</p>
  
  <pre><code>ssh -x $username@$node 'rm -rf statuslist
                          mkdir statuslist
                          chmod u+x ~/monitor/concat.sh
                          chmod u+x ~/monitor/script.sh
                          nohup ./monitor/concat.sh &amp;
                          exit;'
  </code></pre>