Cron – SVN command works in shell but not in cron. Why not

cronmac-osxosx-lionsvn

I use cron to run an 'svn up' nightly on a directory of files that I need to keep up to date locally while others are working on them. This used to work fine, with a simple:

/usr/bin/svn up /path/to/directory

However, ever since I updated to OS X Lion the other day, the command above works fine in the shell (bash) but when it runs from cron I get

Authentication realm: <https://my-server.com:443> my-server.com Subversion Repository
Password for 'my.username':
Authentication realm: <https://my-server.com:443> my-server.com Subversion Repository
Username: svn: OPTIONS of 'https://my-server.com/path/to/directory': authorization failed: Could not authenticate to server: rejected Basic challenge (https://my-server.com)

I desperately tried adding –config-dir to the command, but it had no effect. The auth credentials seem fine, and in any case they work in bash. I know enough to be dangerous, but I'm at the end of my set of tools here.

Can someone point me in the right direction?

Best Answer

svn is looking for your authentication info that is saved in /home/username/.subversion/auth. But as Mike mentioned, the env is not the same under cron and $HOME is probably different. Try setting $HOME before running 'svn up'.

In /etc/crontab:

0 0 * * * username export HOME=/home/username; /usr/bin/svn up /path/to/update