Greeting's,
I am running an apache2 server on my raspberry pi. I wanted to keep a tab on it's temperature while I'm travelling. I know that following two commands will give me the GPU and CPU temperature:
GPU = vcgencmd measure_temp
CPU = cat /sys/class/thermal/thermal_zone0/temp
I also know that I can send an email using SSMTP. I will be using Gmail for this. I don't need help with sending email.
What I need help with is creating a file or a variable that will store the data every hour when the cron job runs and email the output at the end of the day. I would also like to flush this variable at the end of the day. I am using a variable as opposed to sending a file for the sake of easy reading on mobile client (instead of opening an attachment).
#!/bin/bash
# Script: temp_email.sh
# -------------------------------------------------------
cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp)"
echo "CPU => $((cpu/1000))'C"
How do I tie all of this together to send me a single email once every 24 hours with temperature of the Pi measured and stored once per hour?
PS: I'm running RASPBIAN STRETCH LITE in headless mode.