Stop Torrents automatically after 5 days
-
- Posts: 3
- Joined: Sun Dec 19, 2010 6:20 pm
Stop Torrents automatically after 5 days
How can I stop torrents after they are seeding 5 days or even better how to stop them if they have a specific ratio or after seeding 5 days? I'm running transmission 2.12 headless on a Linux NAS at the moment. (with root terminal login)
Re: Stop Torrents automatically after 5 days
Something like this:
Change the global variables to match your user and password (usually transmission and transmission if not changed).
The line that's actually removing the torrent is commented (echo -e "\ttrans...") so you can test it first in your sytem. When you are sure is working for you, change the line for
I tested this on Ubuntu 10.04.1 LTS using transmission-daemon version 2.13 (11501) from ppa.
I hope it helps.
Code: Select all
#!/bin/bash
# Global variables
USER=your_transmission_user
PASSWD=your_transmission_password
# Obtain index ids of completed torrents.
torrent_ids=$(transmission-remote -n $USER:$PASSWD -l\
| awk '$5=="Done"{print $1}')
for index in $torrent_ids; do
# Get creation date from torrent details.
created=$(transmission-remote -n $USER:$PASSWD -t $index -i\
| grep "Date added:"\
| cut -d: -f2-\
| sed 's/^ *//')
echo -e "Torrent $index:\n\tcreated:$created"
# Calculate torrent's age.
# Convert dates to timestap so they can be substracted.
now_ts=$(date +%s)
torrent_ts=$(date +%s -d "$created")
# Substract timestamps and get days difference.
secs_in_day=86400
age=`echo \($now_ts - $torrent_ts\) / $secs_in_day| bc`
echo -e "\tthat's $age days old."
# If it's older than 5 days old, delete it.
if [ $age -ge 5 ]; then
echo -e "\t *** Removing ***"
echo -e "\ttransmission-remote -n $USER:$PASSWD -t $index --remove-and-delete"
else
echo -e "\tKept."
fi
done
The line that's actually removing the torrent is commented (echo -e "\ttrans...") so you can test it first in your sytem. When you are sure is working for you, change the line for
Code: Select all
transmission-remote -n $USER:$PASSWD -t $index --remove-and-delete
I hope it helps.
-
- Posts: 3
- Joined: Sun Dec 19, 2010 6:20 pm
Re: Stop Torrents automatically after 5 days
Thank you very much
Sorry for the late reply... xmas ... relatives.... ^^

Sorry for the late reply... xmas ... relatives.... ^^