title: python - running ssh/rsync commands in a script called via crontab
body: <p>I have a very strange issue that I can't seem to figure out. </p>
  
  <p>When I execute a python script containing the following lines while inside a SSH terminal (putty), it works fine. But the moment I run the script via crontab or even <code>nohup python myscript &gt;/dev/null 2&gt;&amp;1&amp;</code> it doesn't seem to execute these commands.</p>
  
  <pre><code>subprocess.call('rsync -avr /path/to/folder/. --include "delta.*" --exclude "*" -e "ssh -o StrictHostKeyChecking=no -i /path/to/key.pem" ec2-user@'+server+':/path/to/folder/', shell=True)
  local('ssh -t -o StrictHostKeyChecking=no -i /path/to/key.pem ec2-user@'+server+' "sudo /usr/bin/indexer -c /path/to/sphinx.conf --merge main delta --rotate"')
  </code></pre>
  
  <p>Basically all the above is doing is syncing a folder with new sphinx search engine updates to a remote server, then the second line runs a remote ssh command to force the search engine to rotate updates into production.</p>
  
  <p>I do have fabric installed (hence the local command) but to avoid having to fab a second file I was hoping a single line of code could allow me to execute sudo commands on a remote server.</p>
  
  <p>Can someone help me out?</p>