1

I have a collection on a server containing ~23 million documents. I need to index this collection and obviously this will take a long time. If I run this indexing operation with background: true while using the mongo shell through ssh on the server, if I then close the ssh session with that shell query running, will the operation continue to run?

EDIT for more info: e.g if I have

> db.journeys.ensureIndex({startStationName: 1}, {background:true})

This blocks further queries in that session. I know that I can start a new session and access the db as background:true but if I close this session (I can't keep my laptop connected to the internet for the 30+ hours this query will take), will the indexing operation continue?

1

Once a background build is initiated, it will be a background process.

The reason why the shell is blocking is to give you a feedback. You can safely quit the ssh session.

  • Thanks, have tested and can verify that this is working. The indexing continues even if I close the session where I initiated. It turned out I didn't need screen or tmux so I've selected this as the answer rather than Janne's input – Oscar Robinson Oct 7 '14 at 13:39
  • for reference, you can check to see if the index build is still running on the mongod by running db.currentOp() from the mongo shell or by looking in the logs for that instance (it will log index build progress periodically and give you a percentage completion figure). – Adam C Oct 7 '14 at 18:05
  • Thanks, I discovered this yesterday and my indexing is now happily running on the server in the background (currently at 30% after 24 hours -_-) – Oscar Robinson Oct 8 '14 at 13:00
0

Why not to use screen or tmux and be worry-free?

  • Sure, I could even just access the server with a new tab on my local terminal but that's not what I'm asking, edited my question to try and make it a bit clearer. – Oscar Robinson Oct 7 '14 at 10:41
  • If you run Mongo shell inside screen or tmux session, Mongo shell sure remains running even if your laptop says Kaboom. You can re-attach to screen/tmux session later from whatever device you want. What part of your question I misunderstood? – Janne Pikkarainen Oct 7 '14 at 10:44
  • Oh sorry it seems I misunderstood your answer as I'm not familiar with those tools, thanks for the info – Oscar Robinson Oct 7 '14 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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