Skip to content

Instantly share code, notes, and snippets.

@PatelUtkarsh
Last active April 7, 2021 08:46
Show Gist options
  • Save PatelUtkarsh/b9c4b07bd6442ae284d897baf75e70d3 to your computer and use it in GitHub Desktop.
Save PatelUtkarsh/b9c4b07bd6442ae284d897baf75e70d3 to your computer and use it in GitHub Desktop.
Setup cron to monitor raspberry pi temperature
#!/bin/bash
# Usage ./temperature_cron.sh $HOME/pi-temp-log
timestamp=`date +%F`
temp=`/opt/vc/bin/vcgencmd measure_temp`
temp=${temp:5:16}
mkdir -p $1 # make sure dir exists
echo "$(date +%H:%M:%S) = $temp" >> $1/temperature_log_$timestamp.txt # create new file for each day.
@PatelUtkarsh
Copy link
Author

PatelUtkarsh commented Apr 7, 2021

To log temp every 5 mins steps:

  1. crontab -e edit linux cron tab.
  2. Pick nano editor if you're doing it for the first time.
  3. */5 * * * * $HOME/script/path/temperature_cron.sh $HOME/pi-temp-log
  4. Save and close nano. (Ctrl+x)
  5. 🎉 Now watch temp files in tail -f $HOME/pi-temp-log/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment