Created
July 12, 2022 00:01
-
-
Save jrichardsz/243d2968270f6f9c2e09b92a4521dff2 to your computer and use it in GitHub Desktop.
bash file change detector
This file contains 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
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