Guest User

Untitled

a guest
Jul 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #!/bin/sh
  2. PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/bin:/sbin
  3. USER='<username>'
  4. SERVICE='rtorrent'
  5. FILE="/home/$USER/rtorrent/.session/rtorrent.lock"
  6. HOMEDIR="/home/$USER"
  7. SIZE=95 #total %age
  8.  
  9. df $HOMEDIR| tail -1 | while read fs size used avail pcnt mount;
  10. do
  11. pcnt=$(echo ${pcnt} | cut -d'%' -f1 )
  12. if [ ${pcnt} -ge $SIZE ]; then
  13. echo "Running out of space \"${fs} (${pcnt}%)\" on ${HOSTNAME} as on $(date)"
  14. exit 1
  15. fi
  16.  
  17. if pgrep -u $USER $SERVICE > /dev/null
  18. then
  19. echo "$SERVICE service running, everything is fine"
  20. else
  21. rm -f ${FILE}
  22. echo "$SERVICE is not running, starting $SERVICE" && screen -d -m -S rtorrent $SERVICE
  23. fi
  24. done
Add Comment
Please, Sign In to add comment