Bash Advice on how to act on continually updated timestamp
Hey all. I'm new to here, not new to bash, written a lot of scripts but typically they're quite simple.
I'll do my best to describe what I'm trying to do. So I've got this script which monitors a local port for events from my motion sensors at home from an interface hooked up to my computer.
Every time the motion sensor sees some action it updates the variable m1_seen to the current time. What I want it is to add a condition where IF timestamp greater than 1 hour ago, do some action.
The issue is this current while read only loops when there is input from /dev/tcp/localhost/1099. Of course if there is no motion events, the script doesnt loop, so I dont get a chance to perform an action.
I was thinking somehow I need to send this variable's value off to another script/loop, and this loop would check every minute to compare m1_seen to current time and perform an action. Any advice? I hope I'm being descriptive.
while read <&6
if [[ "$REPLY" =~ .*RF.*HouseUnit.*M1.*On.* ]]
echo "M1 Last Seen: $m1_seen" >&1;
echo "pl a10 bright 10" >&6; #understanding this line is of no consequence
# <do something else>