Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Created July 12, 2022 00:01
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 jrichardsz/243d2968270f6f9c2e09b92a4521dff2 to your computer and use it in GitHub Desktop.
Save jrichardsz/243d2968270f6f9c2e09b92a4521dff2 to your computer and use it in GitHub Desktop.
bash file change detector
modified_info=/var/log/eb-docker/containers/eb-current-app/unexpected-quit.log.meta
log=/var/log/eb-docker/containers/eb-current-app/unexpected-quit.log
if [ ! -f $modified_info ]; then
_date=$(stat -c %y "$log")
echo $_date >> $modified_info
exit 0
fi
last_modification_date=$(awk '/./{line=$0} END{print line}' $modified_info)
now_date=$(stat -c %y "$log")
if [ -z "${last_modification_date}" ]
then
echo $now_date >> $modified_info
exit 0
fi
if [[ $now_date != $last_modification_date ]]
then
echo "changed!"
echo $now_date >> $modified_info
else
echo "not changed!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment