怎么在ovh5g中实现30分钟自动清理已完成的种子
请教各位高手,怎么在ovh5g的盒子中实现下面三点(机器装了ubuntu系统、deluge和flexget的):1、每10分钟检测一次硬盘写满溢出并清除溢出种子释放资源,同时自动解锁Flexget。
2、30分钟自动清理已完成的种子释放硬盘空间,正在下载的种子不受影响。
3、每天北京时间2点55分自动重启VPS释放资源,防止长时间运行资源耗尽。完美实现7×24小时全自动运行。
请各位高手帮帮忙,在什么系统条件不要紧,最重要是下载器是deluge。谢谢了!!! 太高端了 俺只会手动...{:7_725:} 这个要求真高。。。 这个只能等大神了{:7_725:} 这个我也想知道{:7_754:} LZ就这么舍不得HDC的那2000积分? 此脚本专为5G小盒而生。
将此脚本保存在/root/autoclean.py 下,运行crontab -e
加1行
*/1 * * * * /usr/bin/python /root/autoclean.py
即可每分钟执行一次。
配置说明:
MAX_WAIT_TIME = x x代表x分钟不活动后就删种
MIN_UPLOAD_SPEED = x * 1024 x 代表上传速度小于x kb就认为种子不活动
此脚本同时也会删除Queued 和 Error这两种状态的种子。from deluge.ui.client import client
from twisted.internet import reactor
from twisted.internet import defer
from deluge.log import setupLogger
import json
import time
MAX_WAIT_TIME = 10
MIN_UPLOAD_SPEED = 50 * 1024
db = {}
def donothing(status):
return status
def on_get_torrents_status(torrents_status):
global db
global MAX_WAIT_TIME
global MIN_UPLOAD_SPEED
tlist = []
for torrent_id in torrents_status:
torrent_info = torrents_status
if torrent_info['state'] == 'Seeding':
if not db.has_key(torrent_id):
db = 0
if torrent_info['upload_payload_rate'] < MIN_UPLOAD_SPEED:
db = db + 1
else:
db = 0
if db > MAX_WAIT_TIME:
db.pop(torrent_id)
tlist.append(client.core.remove_torrent(torrent_id, True).addCallback(donothing))
iftorrent_info['state'] == 'Queued':
tlist.append(client.core.remove_torrent(torrent_id, True).addCallback(donothing))
iftorrent_info['state'] == 'Error':
tlist.append(client.core.remove_torrent(torrent_id, True).addCallback(donothing))
if len(tlist) > 0:
defer.DeferredList(tlist).addCallback(Cleanup)
time.sleep(3)
else:
Cleanup(True)
def Cleanup(status):
global db
client.disconnect()
try:
f = open('autoclean.db', 'w')
f.write(json.dumps(db))
f.close()
except:
db = {}
reactor.stop()
def on_connect_success(result):
client.core.get_torrents_status(None,
['id', 'name', 'state', 'ratio', 'progress', 'upload_payload_rate', 'total_seeds', 'total_peers']).addCallback(on_get_torrents_status)
def on_connect_fail(result):
print "Connection failed!"
print "result:", result
setupLogger()
try:
f = open('autoclean.db', 'r')
db = json.loads(f.readlines())
f.close()
except:
db = {}
d = client.connect()
d.addCallback(on_connect_success)
d.addErrback(on_connect_fail)
reactor.run()来自HDC豪门区
可供参考
jaychous 发表于 2012-10-6 00:19 static/image/common/back.gif
此脚本专为5G小盒而生。
将此脚本保存在/root/autoclean.py 下,运行crontab -e
加1行
真牛,还真有这样的呀 本帖最后由 wasd77008800 于 2012-10-6 01:23 编辑
话说HDC豪门区 在哪 好高端
好強{:7_727:}{:7_727:}{:7_727:}{:7_727:} 还差个 flexget自动获取rss连接。
我觉得应该再添加个脚本,检测硬盘容量,保证有足够空间让种子文件能下载到OVH上。
然后deluge实时检测下载目录,每当文件被脚本删除以后,保证新下的种子文件能执行下载{:7_734:}这样就完美了吧。。。 这个真是高科技了~ jaychous 发表于 2012-10-6 00:19 static/image/common/back.gif
此脚本专为5G小盒而生。
将此脚本保存在/root/autoclean.py 下,运行crontab -e
加1行
我一直没搞懂,这么长的脚本,也要像申请盒子教程里面那几条一样,复制一行回车一下嘛?还是直接点下面的复制代码,一次性黏贴回车啊? wasd77008800 发表于 2012-10-6 00:54 static/image/common/back.gif
话说HDC豪门区 在哪
你到编剧级别就能看见了 这贴让我很无语{:7_738:} 真是太強了
這行動不得了!! 什么事豪门区???? 进来学习一下
页:
[1]