Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/bin:/sbin
- USER='<username>'
- SERVICE='rtorrent'
- FILE="/home/$USER/rtorrent/.session/rtorrent.lock"
- HOMEDIR="/home/$USER"
- SIZE=95 #total %age
- df $HOMEDIR| tail -1 | while read fs size used avail pcnt mount;
- do
- pcnt=$(echo ${pcnt} | cut -d'%' -f1 )
- if [ ${pcnt} -ge $SIZE ]; then
- echo "Running out of space \"${fs} (${pcnt}%)\" on ${HOSTNAME} as on $(date)"
- exit 1
- fi
- if pgrep -u $USER $SERVICE > /dev/null
- then
- echo "$SERVICE service running, everything is fine"
- else
- rm -f ${FILE}
- echo "$SERVICE is not running, starting $SERVICE" && screen -d -m -S rtorrent $SERVICE
- fi
- done
Add Comment
Please, Sign In to add comment