Skip to content

Instantly share code, notes, and snippets.

@dwdraju
Created July 6, 2018 06:50
Show Gist options
  • Select an option

  • Save dwdraju/7bc3bb353cfff7928e41ce05d7a68c77 to your computer and use it in GitHub Desktop.

Select an option

Save dwdraju/7bc3bb353cfff7928e41ce05d7a68c77 to your computer and use it in GitHub Desktop.
git pull sync
#!/bin/bash
LOCKFILE=/home/ubuntu/docker.lock
if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then
echo "already running"
exit
fi
# make sure the lockfile is removed when we exit and then claim it
trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT
echo $$ > ${LOCKFILE}
#do git pull
cd /home/ubuntu/[git-folder]
git pull
sleep 1s
rm -f ${LOCKFILE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment