Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
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

5 Answers 5

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

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

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. http://apple.stackexchange.com/questions/18832/ssh-under-cron-stops-working-in-os-x-10-7-lion

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/script.sh

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

 
discard

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.