courtsopen/dead-man-qry.bash

16 lines
419 B
Bash
Raw Normal View History

#!/bin/bash
NUMHRS=6
# set now variable
NOW=$(date -u +"%Y-%m-%d %H:%M:%S")
RESULT=$(sqlite3 /var/www/tenniscourtsopen.com/courtsopen.db "select published_at from Alerts where datetime(published_at) > datetime('${NOW}', '-${NUMHRS} hours') order by datetime(published_at) limit 1")
# this returns expected string!!!
# echo $RESULT
if [ -z "$RESULT" ]; then
echo "No data from device in last $NUMHRS hours."
fi