title: Setting a delayed shutdown time on a remote LInux via SSH then exiting
body: <p>I have looked at all the answers here on SOF, and not seen what would work.</p>
  
  <h2>My goal:</h2>
  
  <p>Have a EC2 QA server halt itself 55 minutes after last usage</p>
  
  <h2>My strategy:</h2>
  
  <p>Everytime the remote machine is used, it is first checked to see if it is running. If it is, then do the following:</p>
  
  <ol>
  <li>ssh into machine</li>
  <li>run 'sudo shutdown -c' #clears last pending shutdown</li>
  <li>run 'sudo shutdown -h +55' #restarts timer for 55 minute shutdown</li>
  <li>exit</li>
  </ol>
  
  <p>Go about my script's business</p>
  
  <h2>What Works:</h2>
  
  <p>All commands work locally 1 and 2. Numbers 3 and 4 are partial as explained below.</p>
  
  <h2>What Doesn't Work:</h2>
  
  <p>The line invoking the new shutdown halt, it waits for the ssh connection to shutdown, which never does for the versions of the command without '&amp;' at the end.</p>
  
  <h2>What I've tried:</h2>
  
  <p>echo "nohup sudo shutdown -h +55; exit" | ssh -i $HOME/.ec2/cert_name root_user_name@i.p.ad.dress</p>
  
  <p>echo "nohup sudo shutdown -h +55&amp; exit" | ssh -i $HOME/.ec2/cert_name root_user_name@i.p.ad.dress</p>
  
  <p>echo "sudo shutdown -h +55&amp; exit" | ssh -i $HOME/.ec2/cert_name root_user_name@i.p.ad.dress</p>
  
  <p>ssh -i $HOME/.ec2/cert_name root_user_name@i.p.ad.dress nohup sudo shutdown -h +55</p>
  
  <p>ssh -i $HOME/.ec2/cert_name root_user_name@i.p.ad.dress nohup sudo shutdown -h +55; exit</p>
  
  <h2>What Sort Of Works:</h2>
  
  <p>ssh -i $HOME/.ec2/cert_name root_user_name@i.p.ad.dress nohup sudo shutdown -h +55&amp;</p>
  
  <p>ssh -i $HOME/.ec2/cert_name root_user_name@i.p.ad.dress sudo shutdown -h +55&amp;</p>
  
  <h2>What is 'Sort Of':</h2>
  
  <p>The partially successful commands set up the shutdown, and exit ssh just fine. But they fills the LOCAL screen buffer with the last command results on the REMOTE screen. And that comes out with the results of the next command in the script. </p>
  
  <p>I suppose that I could just issue 'echo "flushing buffer"' twice in a row and clear it. </p>
  
  <p>Anything more complete and cleaner out there?</p>
  
  <p>TIA</p>