mongoDB自动杀执行时间的连接
####shell 执行 mongo -u'root' -p'密码' admin mg.js [root@localhost ~]# cat mg.js var currOp = db.currentOp( { "active" : true, "secs_running" : { "$gt" : 30 } } ); for (op in currOp.inprog) { if ("192.168.10.176" == currOp.inprog[op].client.split(":")[0]) { db.killOp(currOp.inprog[op].opid) } } 最后加入定时任务执行
[root@localhost ~]# cat .mongorc.js
killMyRunningOps = function (clientIp) {
var currOp = db.currentOp( { "active" : true, "secs_running" : { "$gt" : 30 } } );
for (op in currOp.inprog) {
if (clientIp == currOp.inprog[op].client.split(":")[0]) {
db.killOp(currOp.inprog[op].opid)
}
}
}
时来天地皆同力,运去英雄不自由