shell script - check mongod server is running

前端 未结 4 836
既然无缘
既然无缘 2021-02-02 03:57

I have a shell script to do some mongo db actions:

e.g. mongo testdb --eval \"db.dropDatabase()\"

BUT, if the mongod server is not running, I get:

4条回答
  •  无人及你
    2021-02-02 04:35

    If you have administrative rights, you could also do a sudo systemctl status mongod which gives you lots of helpful additional information:

    mongod.service - MongoDB Database Server
       Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
       Active: active (running) since Thu 2019-03-14 09:26:53 UTC; 5 weeks 9 days ago
         Docs: https://docs.mongodb.org/manual
     Main PID: 420 (mongod)
       CGroup: /system.slice/mongod.service
               └─420 /usr/bin/mongod --config /etc/mongod.conf
    

提交回复
热议问题