Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I think I have a long running mongo script tanking my database, but I'm not sure. I was connected to the linux server via SSH and I ran the script like so:

mongo my_database my_script.js

It started chugging away, but it was taking too long, so I hit Ctrl-C and dropped back to the shell. I assumed the script was killed off, but now I'm seeing queries that it contained still running on the database.

How do I get a list of scripts the database is currently running and kill them? I know about db.currentOp and db.killOp, but the actual queries themselves are quick, I need to kill the script that's running them in a loop.

share|improve this question
    
Ok, the query was tanking our database, so we just restarted the mongod service. Our other secondaries stepped up, which was good, but this is not the solution I was looking for. –  LoveMeSomeCode Mar 28 at 19:09

1 Answer 1

To find any running task with mongo in its name run:

ps -eo pid, command | grep mongo

Which should output you a list with the process ids and the commands currently being executed. When you identify which task you want to kill, grab that associated number (imagine that it's 582) and run:

kill -9 582

This will send a SIGKILL signal.

The SIGKILL signal is sent to a process to cause it to terminate immediately (kill). In contrast to SIGTERM and SIGINT, this signal cannot be caught or ignored, and the receiving process cannot perform any clean-up upon receiving this signal.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.