title: How do I sync a Git-Svn clone through cron?
body: <blockquote>
    <p>For reference, I'm running CentOS 5.5 on the server.</p>
  </blockquote>
  
  <p>I'm working on a distributed project with several other developers, and we're using Git to manage our repositories.  Everything's hosted live on Gitorious and working beautifully.  However, we need a branch in our repository to stay synchronized with an external Subversion repo - kind of like a "vendor branch" within Git.  Reason is: we're building several things based on this existing open source project (WordPress) and want our working copy to inherit any bugfixes they publish in their own repo.</p>
  
  <p>I've got things set up so that we have a separate branch called "wordpress" that can be kept in sync with the live Subversion repo.  To do so, it's as simple as:</p>
  
  <pre><code>git checkout wordpress
  git svn rebase
  git gc
  git push origin wordpress
  </code></pre>
  
  <p>These commands will:</p>
  
  <ol>
  <li>Make sure we're on the WordPress branch</li>
  <li>Re-sync the branch with the live Svn repo</li>
  <li>Run garbage collection (otherwise the repository progressively gets unmanageably large)</li>
  <li>Push the updated branch to our hosted repository on Gitorious</li>
  </ol>
  
  <p>It's easy enough to run these four commands whenever WordPress trunk updates, but that's annoying and a hassle.  I'd love to set this up as a cron job, but I can't seem to figure out how!</p>
  
  <p>I've written a script called <code>wordpress.sh</code> and placed it in the <code>/etc/</code> folder on the server:</p>
  
  <pre><code>#!/bin/bash
  cd /var/www/git/wordpress
  git checkout wordpress
  git svn rebase
  git gc
  git push origin wordpress
  </code></pre>
  
  <p>The script runs just fine.  I can SSH into my server, log in as root, and type <code>. /etc/wordpress.sh</code> and everything works just fine.  But how can I set this up so that cron does things for me?</p>
  
  <p>I've tried manually adding it to crontab (unsuccessfully), using the Webadmin interface in CentOS to add it as an hourly script (unsuccessfully), and now I'm at a loss!  My system logs <em>claim</em> that it's firing (log below):</p>
  
  <pre><code>Feb  4 07:00:01 ---- crond[27745]: (root) CMD (/etc/wordpress.sh    #WordPress mirror)
  Feb  4 07:01:01 ---- crond[27773]: (root) CMD (run-parts /etc/cron.hourly)
  Feb  4 08:00:01 ---- crond[29095]: (root) CMD (/etc/wordpress.sh    #WordPress mirror)
  Feb  4 08:01:01 ---- crond[29142]: (root) CMD (run-parts /etc/cron.hourly)
  Feb  4 09:00:01 ---- crond[29708]: (root) CMD (/etc/wordpress.sh    #WordPress mirror)
  Feb  4 09:01:01 ---- crond[29718]: (root) CMD (run-parts /etc/cron.hourly)
  Feb  4 10:00:01 ---- crond[30328]: (root) CMD (/etc/wordpress.sh    #WordPress mirror)
  Feb  4 10:01:01 ---- crond[30337]: (root) CMD (run-parts /etc/cron.hourly)
  </code></pre>
  
  <p>But nothing actually happens unless I log in and run the script manually.  Ideas?</p>