Hello I have made a script that updates some repos from git merc and svn, then updates a git repo. The script works manually but doesn't work in crontab, here is the script:

cd /var/gitrepo/addons/addonskins && /usr/bin/git pull
cd /var/gitrepo/addons/aurora && /usr/bin/git pull
cd /var/gitrepo/addons/bartender && /usr/bin/git pull
cd /var/gitrepo/addons/dbm && /usr/bin/git pull
cd /var/gitrepo/addons/elvui && /usr/bin/git pull
cd /var/gitrepo/addons/elvui_enhanced && /usr/bin/git pull
cd /var/gitrepo/addons/icehud && /usr/bin/git pull
cd /var/gitrepo/addons/kuinameplates && /usr//bin/git pull
cd /var/gitrepo/addons/xct+ && /usr/bin/git pull
cd /var/gitrepo/addons/kuinameplates && /usr/bin/git pull
cd /var/gitrepo/addons/postal && /usr/bin/svn update
cd /var/gitrepo/addons/recount && /usr/bin/svn update
cd /var/gitrepo/addons/rsa && /usr/bin/svn update
cd /var/gitrepo/addons/skada && /usr/bin/svn update
cd /var/gitrepo/addons/prat && /usr/bin/hg pull
cd /var/gitrepo/addons/askmrrobot && /usr/bin/hg pull
cd /var/gitrepo/addons/prat && /usr/bin/hg pull
cd /var/gitrepo/addons && /usr/bin/git add .
cd /var/gitrepo/addons && /usr/bin/git commit -m 'Automatic update'
cd /var/gitrepo/addons && /usr/bin/git push
cd /var/gitrepo/addons && touch done.txt

It creates the done.txt file, but doesn't seem to run any of the svn updates at least


It would be helpful if you showed us your crontab command.

A few pointers first.

Use full paths when writing cron jobs: eg.

03 05 * * * /bin/bash /home/user/myScript.sh

Also pipe the output to a log file for you viewing pleasure. Both stdout and stderr. eg.

03 05 * * * /bin/bash /home/user/myScript.sh > ~/log/myScript.log 2>&1

See if the Cron job ran at all in the system log

grep CRON /var/log/syslog

These will be helpful when debugging. Now onto you question regarding git and svn

To get SVN working I used this helpful guide(Capture here for reference):

First, install the keychain program. Second, add this to your ~/.bash_profile (we don't need this to run for every terminal, just on login):

# Use keychain to keep ssh-agent information available in a file
/usr/bin/keychain $HOME/.ssh/id_rsa
source $HOME/.keychain/${HOSTNAME}-sh
Tweak as needed for the location of your private SSH keys. Also, make sure your .bash_profile is actually invoked at start-up. When logging into Ubuntu graphically, this may not be the case unless it's sourced in .profile.

Third, add this to the cron job script (if your cron job is a Python program, just wrap it in a shell script):

source $HOME/.keychain/${HOSTNAME}-sh

As for SVN I haven't been able to get it working myself. Stumbled across your post when I was searching the same thing. Will update my answer if I find anything. Update: You can use the config files in ~/.subversion to store your svn password

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.