These lines can be added into a Linux bash script to exit it in case one date/epoch time is too far from current date/epoch.
This script gets first date from a file where the date/time is in epoch format. Second date is current one and is obtained also in epoch format like this:
Code:
date +"%s"
sample result: 1682177916


Code:
# exit script if too bug difference between two dates/epoch
epochnow="$(date +"%s")" && epochthen="$(grep here-phrase-that-match-single-line-in-a-file-on-which-is-epoch-number-and-not-any-other-number /path/to/file|tr -d -c 0-9)" && diff="$(($epochnow - $epochthen))" && if [[ "$diff" -lt 60 ]]; then
# echo "Difference between now and then is less than 7200 seconds. ($diff seconds)"
exit
else
# echo "Difference between now and then is 7200 seconds or more. ($diff seconds)"
echo ""
fi