wiki:Scripts/Scheduler

Version 3 (modified by Waldorf, 10 years ago) (diff)

thx wereHamster and jhujhiti for the feedback!

Bandwidth Scheduler Script

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:
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 [[ $time -ge $start_time && $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