Category Archives: MongoDB

MongoDB Tips

 

# Show all running queries

db.currentOp()

# Kill query

db.killOp(ID)

# Show all running queries > 1 day

db.currentOp().inprog.forEach(
  function(op) {
    if(op.secs_running > 86400) {
      printjson(op.opid); 
      db.killOp(op.opid);
    }
   } )

# Kill all running queries > 1 day

db.currentOp().inprog.forEach(
  function(op) {
    if(op.secs_running > 86400) {
      printjson(op.opid); 
      db.killOp(op.opid);
    }
   } )