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

I've got a shell script that performs some tasks using files from a Subversion repository. I would like the Subversion repository to keep up-to-date, but right now the script runs svn up every time which is annoying if I need to run the script several times in a row.

Since svn up changes the last modified timestamp of the .svn directory (even if there were no new commits), I figured that I could use that to make sure it only runs svn up once per day or so.

I tried finding a simple way of just checking whether the .svn directory is older than a day, but there were many seemingly overkill ways of doing it so I thought I'd ask here in case there's actually a very simple way to do it.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

This is somewhat simple:

[ `find /path/to/.svn -maxdepth 0 -mtime +1 | wc -l` -gt 1 ] && svn up
share|improve this answer
    
Thanks! :) :) :) –  Blixt Nov 3 '10 at 22:54
add comment

Maybe I am missing the big picture here, but can't you just run a once-daily cron job to update the svn repository?

e.g.

crontab -e

then add a

4 * * * /root/updatecron.sh

where updatecron.sh contains

#!/bin/bash
cd /my/directory
/usr/bin/svn up

or something like that?

share|improve this answer
    
The idea is that the directory that has this script is self-contained. I'd rather not set up cron jobs since it's part of an open source project. So deleting the directory of the project should mean it's completely gone. –  Blixt Nov 2 '10 at 22:45
add comment

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.