Skip to content

Instantly share code, notes, and snippets.

@mengzhuo
Created October 16, 2014 11:45
Show Gist options
  • Save mengzhuo/8687d7205c71a2bb00d4 to your computer and use it in GitHub Desktop.
Save mengzhuo/8687d7205c71a2bb00d4 to your computer and use it in GitHub Desktop.
Auto reload by inotify
#!/bin/sh
# Can reload after file changed/modified/created/deleted
echo "Auto reload"
while true; do
ps aux | grep start.py | awk '{print $2}' | xargs kill > /dev/null
$VIRTUAL_ENV/bin/python $PWD/start.py -c ~/config.ini &
inotifywait -r --format '%:e %f' -e modify -e create --exclude="(^svn|\.(swp|pyc|swx|db|swpx)$|^wc)" $PWD
echo "reloading..."
sleep 0.4
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment