I have to read a epoch timestamp (in seconds) from a directory /usr/local/healthcheck.txt
on my Red Hate Enterprise Linux machine every ~10 minutes (polling). I need perform a comparison on the time to check if the timestamp in the healthcheck.txt
file is OLDER than 50 minutes from the current time/timestamp OR if the healthcheck.txt
is non-existent, to throw an error. The timestamp in the healthcheck.txt
file generally looks like this (its in seconds, as stated above) :
1591783065
I was using date -d @1591783065
to convert the timestamp to Human Readable and get something like this:
Tue Jun 9 16:22:57 UTC 2020
What would be the best approach to compare the current timestamp to this timestamp in the file and check if its older than 50 minutes?
In Java , we have a Date
package , and can just use compareTo
to compare the times/dates, is there a simple way to do this with shell/bash scripts?