Is there a way to know if transmission-daemon currently active?

I have a laptop that i use as a media station connected to my TV, occasionally i would fall a sleep and forget to shutdown the laptop and that is unwanted behavior. so i use crontabs to shutdown my laptop everyday at 7AM because i am sure that i am always either asleep or not at home then.

However sometimes i am actually downloading something using transmission-daemon and would prefer the laptop not to turn off at that time. Is there a way to check whether transmission daemon is downloading or not? like a file flag by transmission-daemon? i though about scanning the active ports used by transmission-daemon but i figured that there might be a more elegant solution.

Asked By: Grey Mahagone


Sure. The first one is with transmission not active, the second one is.

rinzwind@schijfwereld:~$ ps -ef | grep transmission | grep -v grep

rinzwind@schijfwereld:~$ ps -ef | grep transmission | grep -v grep
rinzwind 10490     1 11 22:04 ?        00:00:00 transmission-gtk

Is there a way to check whether transmission daemon is downloading or not?

Yes. There is an API and here is an old script from 2013 doing a shutdown for a MAC. Requires 1 change:['osascript', '-e','tell application "Finder" to shut down'])

needs to be something like this:['shutdown', '--now','turn off'])

It assumes you set up the web interface on port 9091

Pre req:

cd ~
virtualenv .transmission_env
source .transmission_env/bin/activate
pip install transmissionrpc

and the script:


import subprocess

import transmissionrpc
from transmissionrpc.error import TransmissionError

def main():
    all_done = True
        tc = transmissionrpc.Client('localhost', port=9091)
        for torrent in tc.get_torrents():
            if torrent.status == 'downloading':
                all_done = False
        if all_done:
  ['osascript', '-e',
                             'tell application "Finder" to shut down'])
    except TransmissionError:

if __name__ == "__main__":
Answered By: Rinzwind
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.