Enable auto shutdown in Transmission with your own script in Linux

transmission shutdownTransmission is a simple yet powerful torrent client. It’s available in some of the Linux distributions by default. However, one very important torrent client must have feature is missing in┬átransmission. Now, we are going to add that feature by ourselves with our own shell script. We will make that shell script execute in Transmission after download completes. Let’s first get started by writing a single line shell script for shutdown. Most of you reading this may have used command to restart and shutdown your system. If you don’t know this, yes you can shutdown and restart Linux system from your terminal.

Go to home directory, fire up your text editor, create a file and write a script. I will use vim. Name the file shutdown.sh and add the following code into that file:

sudo -h shutdown now

Make the file executable:

chmod +x shutdown.sh

More in Chmod and Linux file permissions.

That’s all we would include in the script file.

Now, we will need gksu. If it’s not available in your system by default install it. It’s available in the repo of most Linux distributions. For Debian users:

sudo apt-get install gksu

Drag your Transmission icon in Desktop, right click and under basic heading you will find a command field. Add “gksu command” in that field. Gksu command makes transmission executable as a super user.

auto shutdown in transmission
Or you can start transmission as a root from the terminal.

sudo transmission

Now, go to Edit> Preferences and under Downloading check on “Call Script when torrent is completed”. Give the path of the script file and that’s it.

However, there’s one hassle in this process. If you are downloading more than one torrent at once, your system will shutdown after completing one download. If you have a way to remove this hassle, share with us as a comment.


Posted in Debian, Linux, Linux Application, Shell Scripting | Tagged , , | 6 Comments

6 Responses to Enable auto shutdown in Transmission with your own script in Linux

  1. Tim Bruce UNITED STATES Mozilla Firefox Ubuntu Linux says:

    To add a check for this, I’d probably add something like the following to my script:

    while [ /bin/true ]; do
    COUNT=`ps -ef | grep transmission | grep -v grep | wc -l`
    if [ $COUNT -eq 1]; then
    sleep 60 # Or however many seconds you want to sleep

    I have NOT tested that, so it may or may not work for you.

  2. mymycracra FRANCE Mozilla Firefox Windows says:


    To make sure that another torrent is not running you try to create some kind of a lock and check if the lock is present then no shutdown.

  3. jlan Google Chrome Windows says:

    Or use qbittorrent, a better one (linux, osx and windows)

  4. todd CANADA Mozilla Firefox Ubuntu Linux says:

    Nice useful post.

    Still find it amazing that this feature isnt on every torrent program.

  5. mike UNITED STATES Google Chrome Linux says:

    Perhaps a (very) slightly better alternative would be to enable passwordless sudo for yourself, instead of running the whole application as root to begin with. Then, when the transmission client (which is running as your own logged in user) calls the script, it has permission to use sudo without a password.

    You can use visudo to lock down the passwordless sudo access to only the shutdown command.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>