Advertisement
Guest User

Untitled

a guest
Sep 5th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. SERVICE='motion'
  4. RUN_COMMAND='nice -n 10 /usr/local/bin/motion &'
  5. LOGFILE=/home/pi/motion/motion.log
  6. VOPATH=/media/data/motion # video output directory
  7. LIMIT=90 # maximum disk usage
  8.  
  9. if [ ! $(pidof $SERVICE) ]
  10. then
  11. # process not running, starting
  12. echo "[!!!] [$(date +%c)] check_motion.sh - $SERVICE is not running, starting '$RUN_COMMAND'" >> $LOGFILE
  13. $($RUN_COMMAND)
  14. fi
  15.  
  16. if [ $(df -P $VOPATH | awk '{ gsub("%",""); capacity = $5 }; END { print capacity }') -gt $LIMIT ]; then
  17. echo "Free space is less than $LIMIT, removing 10 oldest files."
  18. cd $VOPATH
  19. rm $(ls -tr | awk 'NR<10')
  20. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement