wiki:Scripts/Scheduler

Bandwidth Scheduler Script

(for other scripts, see the Scripts page)

NOTICE

Functionality of this script has been implemented in libtransmission which makes this script obsolete. You can set the speed limit schedule through the web interface.

Notes

Add this script to cron to make it work.

Script

#!/bin/bash

# The script will limit speed settings between
# the following hours. Note: only use whole
# hours, minutes are not supported!
start_time=10
end_time=22

# Normal speed setting:
normal_speed="-D -U"
# Speed limit setting:
limited_speed="-d100 -u20"

# Authentication "username:password":
#tr_auth="admin:admin"

# Transmission host "ip:port":
tr_host="127.0.0.1:9091"

# Verbose?
verbose=1

#############################################
time=$(date +%H)
if [ -n "$tr_auth" ]; then 
    tr_auth="--auth=$tr_auth"
fi

if [[ $((10#$time)) -ge $start_time && $((10#$time)) -lt $end_time ]]; then 
    /usr/local/bin/transmission-remote "$tr_host" "$tr_auth" "$limited_speed" > /dev/null
    if [ -n "$verbose" ]; then
        date "+%Y-%m-%d (%H:%M:%S) Transmission speed limit changed"; fi
else
    /usr/local/bin/transmission-remote "$tr_host" "$tr_auth" "$normal_speed" > /dev/null
    if [ -n "$verbose" ]; then
        date "+%Y-%m-%d (%H:%M:%S) Transmission speed limit changed"; fi
fi

exit 0
Last modified 11 years ago Last modified on Jan 22, 2010, 12:08:10 PM