Cron Job, Bash Script, SVN


I’ve been trying to run a sh script using crontab today.

It’s a script that pushes changes to a folder on the server, where users upload files etc, to an SVN repository. The script works when I run it from the command line as ‘sh’.

I added the cron job using I set the frequency to every 10 minutes so I could see if it was working, and set the email to my email also to see if it was working.

I checked the crontab with crontab -l when logged in via ssh. And it seems the cronjob was added correctly. In the crontab -l I can see the following:

*/10 * * * * sh -c $’/bin/sh /home/myuser/’

And the bash script looks like as follows:

cd /home/myuser/mysite/svnreponame
svn update
svn add * --force
svn commit -m “Automatic SVN push”

I’m wondering if it’s the different environment that the cron job runs in compared to when I run the script from the shell. When I run the script from the shell it doesn’t ask to save password or what the password is, because I’ve set it up so it remembers the password so that the script can run without any input from me. If the enviroment that the cron job runs in doesn’t have this set, then maybe I need a way to automatically input the password.

If the cron job is stopped mid way through as the svn command is asking for a password, does that mean that I won’t receive an email or notification of it’s failure to run?


I’ve changed the script to use full file paths for everything, as well as to use the username & password in the command line to hopefully eliminate any promps that stop the script :

cd /home/myuser/mysite/reponame
/usr/bin/svn update --username $username --password $password
/usr/bin/svn add * --force
/usr/bin/svn commit -m “Automatic SVN push” --username $username --password $password

Running the script from the ssh shell works. I’ll post back in 10 minutes if it has worked for the cron tab or not.

Edit 2:

Still not running



Try make it executable and just call it directly in the job, foregoing the sh loader.


Yeah, did that yesterday. Also added a mail -s bit to the code so it would definately email me when it runs. Running it as an exectuable from the shell with


executed correctly after I fixed up that #!/bin/bash part. But this morning I haven’t received any emails yet, just checked the repo through ssh, the repository hasn’t updated.

So I’ve fixed up those things you recommended and still no dice.

crontab -l now looks like:

*/10 * * * * /usr/local/bin/setlock -n /tmp/cronlock.3784705249.143296 sh -c $’/home/username/’

and that’s with putting

Into the cron set up in


Perhaps this is an email from the server issue, are you email to and from your own domain, or what domain is the “to”?


Different email domains. I do a ls reponame while in ssh to see if it has worked or not, looking to see if the svn has updated with a file I added to the repo from a different workspace.


It worked when I didn’t use locking. Also after having restarted the cron from a sudo account. I’m going to try restarting cron from a sudo account with the locking on and see if it works and continues working then.