Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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: <> Subversion Repository Password for 'my.username': Authentication realm: <> Subversion Repository Username: svn: OPTIONS of '': authorization failed: Could not authenticate to server: rejected Basic challenge (

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?

share|improve this question
Does your password contain special characters? – quanta Jul 25 '11 at 15:05
I have the same problem. It is not due to shell choice, nor due to path. As in the case of the OP, the output from cron indicates that svn is in fact being run, but the authentication is failing. A can see it asking for a password, and getting no (or incorrect) response. This information is cached in my .subversion settings, since if I run the same command from the command line, I am not even asked for a username or PW. I am issuing a svn export <url> <local filenmae> command. If I issue the same command in the crontab for a svn url that is NOT password protected, then the cronjob works fine. – thomas blom Feb 13 '12 at 5:32

It's likely that this is due to the fact that the same env is not loaded with cron like it is in a standard shell. You can either

  1. source .bashrc or have a script that does that all for you
  2. use the fully qualified application name rather than the simple command you can use because /usr/bin is on the $PATH
share|improve this 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
share|improve this answer

In this very related thread, a user posts some obscure syntax that apparently gets ssh-agent to work. This thread is not svn-specific, but appears to be exactly the same issue.

share|improve this answer

Create a new shell script that content your SVN command. Then put something like this in cron:

/bin/bash /path/to/your/

This will make sure that your command are work in bash envelopment.

share|improve this answer
No dice. Same result as before. – Justin Goeres Jul 25 '11 at 14:10

On OSX you should not be using cron you should be using launchd and launchctl.

Here is a good article that describes the OSX way of doing scheduled jobs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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