I'm running a mongod process on my Centos 6.8 box, and I want to provide some level of resilience in the event of process death. So I created an entry in my /etc/inittab -


To test this, I killed the process, and expected it to restart. But it didn't.

$ service mongod status
mongod dead but subsys locked

This message indicates there's a pid file present /var/run/mongodb/mongod.pid, so init thinks the process is still running.

Question: Is there an automatic way for init to remove the pid file and restart mongod?

  • Have you tried to edit your entry: md:2345:respawn:/usr/bin/mongod to something like this? md:2345:respawn:/usr/bin/env /mongo_start_script.sh in order to include inside the script desired commands like kill mongodb and etc. – Marat Gainutdinov Jun 16 at 14:22
  • Short answer - No. You have to provide the functionality to remove the stale lock file. – fpmurphy Jun 16 at 14:31
  • Is upstart an option? – Andrew Fielden Jun 16 at 14:32
  • 1
    CentOS 6 just used upstart for SysV compatibility and uses very little of its other functionality (as it turned out to be basically garbage and so everyone abandoned it). It's also very close to end of life and it's quite surprising you're still running it. You would not have this problem on CentOS 7 (or 8, which you should just go directly to at this point) as they use systemd, which doesn't suffer this problem and can automatically restart crashed daemons. – Michael Hampton Jun 16 at 14:46
  • 1
    What are they going to do after November 2020, then? – Michael Hampton Jun 16 at 14:57

Your Answer

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

Browse other questions tagged or ask your own question.