Schedule downloads wih transmission daemon

Using transmission-daemon to download linux distributions I need a way to schedule downloads that’s a little more complex than the built-in scheduler.

Most of the time, I don’t want anything happening while I’m at home because it’s hogging the network too much, even at lower speeds.

The built-in scheduler is useless if you have more than a time range to manage. Which is a very common use case. For example, I want to completely stop all downloads before running my backup script.

transmission schedule screenshot

First, I had to come up with a way to do following on the deamon.

  • Start all torrents
  • Stop all torrents
  • Enable turtle mode
  • Disable turtle mode

I could have switched to Deluge because they have a plugin for that (and a lot of things in fact). But I prefer transmission, even though it’s more barebones.

To do that I’m going to use transmission-remote, which is a command line utility that can perform pretty much any action on the daemon.

Here’s the script I’m using to perform all these actions. It’s very simple as you can see.

#!/bin/bash
LOGIN="user:password"
case $1 in
 start*)
 transmission-remote -n $LOGIN -t 1-999 -s > /dev/null
 ;;
 stop*)
 transmission-remote -n $LOGIN -t 1-999 -S > /dev/null
 ;;
 slow*)
 transmission-remote -n $LOGIN -as > /dev/null
 ;;
 full*)
 $0 start
 transmission-remote -n $LOGIN -AS > /dev/null
 ;;
esac

With that script and the power of crontab, now it’s just a matter of calling it when needed, with one the arguments : [start|stop|slow|full]

Here a scenario that’s pretty common:

  • Start download when I’m leaving to work
  • Stop it when I’m back home
  • Resume it when I’m going to sleep.
  • Stop all downloads on the weekend

And here’s the crontab for it :

30 17 * * 1-5 /home/$USER/scripts/torrent.sh slow # slow mode starting at 17:30 on weekdays
0 18 * * 1-5 /home/$USER/scripts/torrent.sh stop # stop at 18:00 on weekdays
0 6 * * 6 /home/$USER/scripts/torrent.sh stop # stop at 06:00 on saturday
0 2 * * 1-5 /home/$USER/scripts/torrent.sh full # full speed at 02:00 on weekdays

As you can see, managing a schedule for transmission-daemon with the crontab is easy. And in fact, it offers more flexibility than the deluge plugin because it’s so powerful.

 

If you wish to copy this method, just copy the script in ~/scripts/torrent.sh and you can add the appropriate entries in your crontab. Replace $USER by your username.

If you’re not familiar with the crontab, I find crontab.guru very useful for the complex cases.

Stephen B

Développeur informatique passionné de numérique et de technologie au sens large du terme.