For reference, I am running CentOS 5.5 on the server.
I am working on a distributed project with several other developers, and we use Git to manage our repositories. Everything was hosted on Gitorious and worked great. However, we need a branch in our repository to stay in sync with the external Subversion repository - sort of like a “provider branch” inside Git. The reason is that we are building a few things on the basis of this existing open source project (WordPress) and we want our working copy to inherit any corrections that they publish in their own repo.
I have settings, so we have a separate branch called "wordpress" that can be stored in sync with the Live Subversion repo. To do this, it is simple:
git checkout wordpress
git svn rebase
git gc
git push origin wordpress
These teams will:
- Make sure we are in the WordPress thread
- Re-sync branch with Live Svn registry
- Start garbage collection (otherwise the repository gradually becomes unmanageable)
- Click the updated branch in our hosted repository on Gitorious
It's easy to run these four commands whenever the WordPress trunk is updated, but it's annoying and hassle. I would like to set this up as a cron job, but I can't figure out how to do this.
I wrote a script called wordpress.shand placed it in a folder /etc/on the server:
#!/bin/bash
cd /var/www/git/wordpress
git checkout wordpress
git svn rebase
git gc
git push origin wordpress
script . SSH , root . /etc/wordpress.sh, . , cron -?
crontab (), Webadmin CentOS, script (), ! , ( ):
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)
, script . ?