Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- SERVICE='motion'
- RUN_COMMAND='nice -n 10 /usr/local/bin/motion &'
- LOGFILE=/home/pi/motion/motion.log
- VOPATH=/media/data/motion # video output directory
- LIMIT=90 # maximum disk usage
- if [ ! $(pidof $SERVICE) ]
- then
- # process not running, starting
- echo "[!!!] [$(date +%c)] check_motion.sh - $SERVICE is not running, starting '$RUN_COMMAND'" >> $LOGFILE
- $($RUN_COMMAND)
- fi
- if [ $(df -P $VOPATH | awk '{ gsub("%",""); capacity = $5 }; END { print capacity }') -gt $LIMIT ]; then
- echo "Free space is less than $LIMIT, removing 10 oldest files."
- cd $VOPATH
- rm $(ls -tr | awk 'NR<10')
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement