Skip to content

Instantly share code, notes, and snippets.

@mkody
Created November 9, 2015 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkody/7e0026d72450aed2a7d1 to your computer and use it in GitHub Desktop.
Save mkody/7e0026d72450aed2a7d1 to your computer and use it in GitHub Desktop.
Watch for a file change
#!/bin/bash
# Will check for remote file change. Be aware, it downloads the file.
# (Made at first to execute a php script to notify when a file was updated)
# USAGE: `./watch.sh "http://exemple.com/file"`
curl -s -o "temp-dl" "$1"
firsthash="$(md5sum 'temp-dl')"
counttime="0"
while :
do
sleep 120
curl -s -o "temp-dl" "$1"
newhash="$(md5sum 'temp-dl')"
if [ "$firsthash" != "$newhash" ]
then
#curl -s "http://[...]"
echo "FILE UPDATED"
rm temp-dl
break
fi
counttime=$(( $counttime + 2 ))
#echo $counttime
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment