DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2010-11-01 04:35:16

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Clearing completed torrents from Transmission

I wrote a simple perl script that queries Transmission (via transmission-remote) for a list of any completed torrents and then deletes them. I run it via cron once a day to clean things up. I thought someone else may benefit from it as well.

Code:

#!/ffp/bin/perl

# tr_port is the port that transmission admin is running on
$tr_port = 9090;

# tr_bin is the path and name of transmission-remote executable
$tr_bin="/ffp/bin/transmission-remote";

$tdate = `/ffp/bin/date`;
chomp($tdate);
$tdate =~ s/E.T //ig;
#print $tdate." Running $0\n";

# query for any completed torrents
@trn_items=`$tr_bin $tr_port -l|grep "Finished"`;

foreach $item(@trn_items) {
  $item =~ s/^\s+//;
  while ( $item =~ m/  / ) { $item =~ s/  / /ig; }
  @b = split(/\s/,$item);
  $tname = $b[9];
  for ($i=10; $i<=($#b+1); $i++) { $tname .= " ".$b[$i]; }
  print $tdate." Removal of torrent [".$b[0]."] ".$tname;
  # delete the finished torrent entry
  $result = `$tr_bin $tr_port -t $b[0] -r`;
  chomp($result);
  print ( $result =~ m/success/i ? "Succeeded\n" : "Failed ".$result."\n" );
}

# eof

Last edited by FunFiler (2010-11-02 00:02:21)


Attachments:
Attachment Icon trans_cleanup.pl, Size: 832 bytes, Downloads: 160

3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB