Skip to content

Instantly share code, notes, and snippets.

@coffeejunk
Created September 26, 2011 13:45
Show Gist options
  • Save coffeejunk/1242263 to your computer and use it in GitHub Desktop.
Save coffeejunk/1242263 to your computer and use it in GitHub Desktop.
#!/bin/sh
unset GIT_DIR
cd ..
git reset HEAD --hard
# kill the scheduler if running
pid=$(ps a | grep 'sched.rb' | grep -v 'grep' | cut -d ' ' -f 1)
if [ ! -z "$pid" ]; then
# scheduler script running
kill $pid
fi
# if no screen session exists create one.
if [ -z "$(screen -ls | grep 'rb-sched')" ]; then
screen -dmS rb-sched
# have to wait a bit otherwise the command will not be executed
sleep 1
fi
# restart scheduler in screen session
screen -S rb-sched -X stuff "ruby sched.rb `echo '\015'`"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment