title: how to ssh into a machine, run a command and return before the command has completed
body: <p>is it possible to ssh into a machine, run a command and return before the command has completed.</p>
  
  <p>I've tried doing it in the snippet of bash script below</p>
  
  <pre><code>for ip in $ipaddrs
  do
      ssh pi@192.168.1.$ip 'sudo apt-get update' &gt; /dev/null &amp;
  done
  </code></pre>
  
  <p>thanks</p>
  
  <p>update:
  an issue is that I'm updating multiple machines and as the output stream is sent to null, I won't know if its worked (which I'm unsure it will) until its finished. Is it possible to use tmux in the script instead?</p>
  
  <p>so ssh in, start tmux, start the update in the tmux shell, detach from the tmux shell and close the ssh session.</p>
  
  <p>then if needs be, I can always ssh into a few machines and reattach the tmux shell to check all is well.</p>
  
  <p>-how do you start tmux in a script?
  -how do you detach from tmux in a script?</p>