Skip to content

Instantly share code, notes, and snippets.

@tpreviero
Created March 14, 2024 08:24
Show Gist options
  • Save tpreviero/a01aecde576f6972ad0178d0ac6cd283 to your computer and use it in GitHub Desktop.
Save tpreviero/a01aecde576f6972ad0178d0ac6cd283 to your computer and use it in GitHub Desktop.

Assuming the script is located in ~/crontabs/, this needs an edit in the crontab file:

HOUSE_POWER_CHECK_DEPLOYMENT_ID="<INSERT HERE THE DEPLOYMENT ID FROM GOOGLE APP SCRIPTS>"
*/10 * * * * ~/crontabs/house-power-check-heartbeat.sh

It's also helpful to have in the /etc/logrotate.conf the following:

/home/<YOUR HOME>/crontabs/house-power-check-heartbeat.log {
  daily
  rotate 2
}
#! /bin/bash
OUT=$(curl -L "https://script.google.com/macros/s/$HOUSE_POWER_CHECK_DEPLOYMENT_ID/exec?type=heartbeat")
if [ "$OUT" = "{\"status\":\"OK\"}" ]; then
echo "Heartbeat OK" >> ~/crontabs/house-power-check-heartbeat.log
else
echo "Hearbeat failed!" >> ~/crontabs/house-power-check-heartbeat.log
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment