HowTo: Schedule your BitTorrent client to run only during specified times automatically.
Like most people, I torrent files, but it really can eat into my download quota. As I have separate on-peak and off-peak download quotas where the latter is more substantial than the former, I prefer to have my BitTorrent client download only during off-peak times.
Sure, some BT clients have in-built timers to do this for you, but they are not always reliable. One sure fire way of making sure it all works is to start and stop the BT client itself.
How does one configure the client to start and stop at specified times so you don’t have to baby-sit your PC to start & stop your BitTorrent client manually? We can use a very useful little app available on all Linux distributions called cron.
In this example, I use the popular Azureus BitTorrent client, but you can adapt this to any GUI app. All you need to know is the path to the program executable. In the case of Azureus, it’s /usr/bin/azureus on a vanilla Ubuntu system.
We will schedule two tasks to be started by cron – one to start Azureus at a specified time and the other to terminate it. To do this, we need to make use of crontab. Open up a terminal and type in:
$ crontab -e
…and you will be presented with your terminal text editor (typically Nano in Ubuntu) showing you the current content of your contab file.
At the bottom of the file, add the following lines:
# Start Azureus at midnight so it uses the off-peak download quota.
0 0 * * * DISPLAY=:0 /usr/bin/azureus &
# Kill Azureus nicely at midday to prevent eating into the on-peak download quota.
0 12 * * * ps -eo pid,args | grep azureus | awk '{print $1}' | xargs -I {} kill {}
When you’re done, press CTRL + X, press Y to confirm overwriting the old crontab and your changes will be saved. You can verify the edits by listing your crontab as follows:
$ crontab -l
What we’ve done here is schedule the main Azureus app to start at zero minutes past zero hours (midnight) on any day of the month of any month on any day of the week on the default monitor (DISPLAY=:0). The ampersand on the end ensures that the app starts in its own task in the background. Note that if you are not starting a GUI application, you don’t need to specify the DISPLAY=:0 bit.
The second crontab entry will terminate the Azureus task at zero minutes past the 12th hour (midday) on any day of the month of any month on any day of the week. It does this by using the ps command to determine the Process ID (PID) of the Azureus task and then make a call to kill that PID only.
And that’s it! Azureus will now start and stop when I want it to, as long as my PC remains on.



you could use speed scheduler plug-in of azureus(vuze) instead, much easier and felxible
I agree, however in practice the plugin doesn’t always work. I tried a few scheduler plugins for Azureus before giving up and looking at cron instead, and these days I use Transmission now – far easier, simpler and a smaller footprint than Azureus.
This article was an exercise in absolutely guaranteeing that your torrents stopped when you wanted, plus it’s a small lesson in cron and how it can be used to start and stop other programs.
Just what I needed, thank you. That DISPLAY=:0 bit and the ampersand sorted me out.
Speed Scheduler doesnt close the ports so you still get inbound “are you there?”-type requests during peak bandwidth times, which triggers my ISP’s traffic-shaping on all traffic types.
I’ve tried AzCron, which can close ports and do all sorts, but it keeps on dying.
So this is the only proper solution for me. I had to do a “whereis vuze” to find my full path before it was happy.