Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wonder if it is possible to create such .sh script that a normal user would be capable to start with something like nohup ./ >& /dev/null & and which would once a minute look into some SVN, find out current version and if there was an update run commands like:

kill `ps aux | grep -F 'ServerAPP' | grep -v -F 'grep' | awk '{ print $2 }'` 
cd server/install-dir/
export LD_LIBRARY_PATH=./:~/server/install-dir/lib_boost:~/server/install-dir/lib_openSSL
nohup ./ServerAPP >& /dev/null &

that would kill currently running app, run some auto update script we already have in users home ~ and run it again.

Is it possible to create such script and how to do it?

share|improve this question
Please don't cross post the same question on multiple stackexchange sites. is the original. – psusi Jan 19 '12 at 23:43

The script would look something like this:

#! /bin/bash


REMOTE_REV=`svn info $REMOTE_REPO | grep '^Revision:' | awk '{print $2}'`
LOCAL_REV=`svn info $LOCAL_REPO | grep '^Revision:' | awk '{print $2}'`

if [ $REMOTE_REV -eq $LOCAL_REV ]; then
    exit 0;
    # Run your commands here.
    cd $LOCAL_REPO
    svn up

This script just compares the current revision number of both the local and remote svn repositories. If the differ than it runs some commands. If they are the same, it just exists.

Then you'd just have to set up a cron job to run how often you want.

share|improve this answer

If you have access to svn server, the the better approach is to define svn postcommit hook. This way you avoid polling.

Are we there yet? Are we there yet? Are we there yet? - see how annoying is that?

Advantages of hooks over polling:

  • you will know immediately (not with 1 minute delay) because you tell svn to tell you when anything gets changed.
  • you don't waste your resources for asking and server resources for answering
share|improve this answer

Your Answer


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.