Skip to content

Instantly share code, notes, and snippets.

@Mualig
Last active April 26, 2021 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mualig/66e53beedf6eabc73b3d2c9b62de1e5a to your computer and use it in GitHub Desktop.
Save Mualig/66e53beedf6eabc73b3d2c9b62de1e5a to your computer and use it in GitHub Desktop.
Command to kill old mongo DB ops

Command to kill old mongo DB operations

db.currentOp().inprog.forEach(
    function (op) {
        if (op.secs_running > 5) {
            print("host: " + op.host
                + " secs_running: " + op.secs_running
                + " op: " + op.op
                + " ns: " + op.ns
                //+ " command: " + JSON.stringify(op.command)
            );
            db.killOp(op.opid);
        }
    }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment