Monday, November 3, 2008

svn update every 15 seconds

There's alot of different ways to go about doing this. update svn repo on a timed basis. You can create a small script (1), add it to cron to run every minute or you can just run the script with an infinite loop with sleep 15. (2)

(1) create a new file and call it svn_update.sh
put this inside of the script(I know it clunky, but it works):

#!/bin/sh
svn update $1
sleep 15
svn update $1
sleep 15
svn update $1
sleep 15
svn update $1
sleep 15

Now create a cron to run this script every minute, add this to /etc/crontab:

* * * * * root /dir/to/svn_update.sh /var/www/some_project



That is one way. But that way you have a cron running every minute executing this script when you may not need it, Plus this actually is not 15 seconds really. It turns out to be more like 30 or 45 seconds. Depending on your environment.

(2)This is another way:

Create a file named svn_update.sh and put this in it:

#!/bin/sh
while true;do date && svn update $1 && sleep 15;done


Now when you need to work on your project just start this script and it will update your project directory for you every 16 seconds.

You can run this script in the background like this:

/dir/to/svn_update.sh /var/www/my_big_project_1 &

Like I said there's alot of different way to achieve this and results may vary. That really goes for anything in this world though. Enjoy. Back to my book translation project I go. :)

Oh yeah, make sure to make this script executable.

chmod +x /dir/to/svn_update.sh

You can insert >/dev/null in there somewhere if you don't want verbose output. I like verbose, but it gets annoying sometimes.

No comments: