Created
November 9, 2015 13:43
-
-
Save mkody/7e0026d72450aed2a7d1 to your computer and use it in GitHub Desktop.
Watch for a file change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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