2

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?

Justin Goeres
  • 63
  • 2
  • 4
  • 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 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 05:32

4 Answers4

2

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
Scott Pack
  • 14,717
  • 10
  • 51
  • 83
Mike
  • 21
  • 2
2

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
Bill
  • 36
  • 2
1

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

0

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.

Artiya4u
  • 26
  • 1