Skip to content

Instantly share code, notes, and snippets.

@slavaaaaaaaaaa
Last active February 28, 2018 22:26
Show Gist options
  • Select an option

  • Save slavaaaaaaaaaa/5799915 to your computer and use it in GitHub Desktop.

Select an option

Save slavaaaaaaaaaa/5799915 to your computer and use it in GitHub Desktop.
#!/bin/bash
LOCATION=/home/pi/vids
PART=/
while :; do
TEMP=$(/opt/vc/bin/vcgencmd measure_temp)
DATE=$(date +"%m-%d-%y-%T")
echo "! $DATE-$TEMP.h264 starting..."
sudo raspivid -t 1200000 -o $LOCATION/$DATE-$TEMP.h264
DISKUSAGE=$(df -h $PART | grep dev | awk '{ print $5}' | sed 's/%//g')
echo "! $DATE-$TEMP.h264 done at $(date +"%m-%d-%y-%T"), disk at $DISKUSAGE."
if [ $DISKUSAGE -ge 99 ]
then
if [ $LOCATION == "/media/vids" ]
then
echo "!! Out of space! Bye!"
break;
fi
echo "!! Switching to USB drive"
LOCATION=/media/vids
PART=/media
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment