Scheduling Transmission via crontab

I am on a 1Mbps BSNL broadband connection that gives unlimited free downloading from midnight 2AM to morning 8AM which I must confess I haven’t been utilizing till now. Sitting bored at home, I now need to download some movies (torrent, of course!) during these hours, thus making sure that I do it without the fear of any HUGE bill from my ISP by the end of the month.

The solution was simple: add the torrent(s) in Transmission and then create the below script, and then a crontab to run it during 2AM:

[vimal@vimal ~]$ vi /home/vimal/transmission_crontab.sh

#!/bin/bash
args=("$@")
if [ $args == "start" ]
 then
   export DISPLAY=:0.0
   /usr/bin/transmission &
   exit 0
 elif [ $args == "stop" ]
 then
   torrent_count=`transmission-remote --list 2>&1 | wc -l`
   if [ $torrent_count -gt 1 ]
    then
     torrent_count=$(($torrent_count-2))
     for i in `seq 1 $torrent_count`
     do
       transmission-remote -t $i -S > /dev/null 2>&1
     done
   fi
fi

[vimal@vimal ~]$ chmod +x /home/vimal/transmission_crontab.sh

Set a crontab to start it at 2AM, and pause downloads at 8AM:

[vimal@vimal ~]$ crontab -e

00 02 * * * /bin/sh /home/vimal/transmission_crontab.sh start
00 08 * * * /bin/sh /home/vimal/transmission_crontab.sh stop

Done! The torrents will get downloaded at 2AM while you sleep and stop by 8AM :-) I am not advocating torrents here, just a friendly reminder that download and use torrents at your own risk!!

Share:
  • del.icio.us
  • Digg
  • Facebook
  • Google Bookmarks
  • Google Buzz
  • LinkedIn
  • MySpace
  • Reddit
  • RSS
  • StumbleUpon
  • Technorati
  • Twitter
You can leave a response, or trackback from your own site.

One Response to “Scheduling Transmission via crontab”

  1. Anees says:

    Hats off to you, man…. :)

Leave a Reply