shell script - check mongod server is running

前端 未结 4 845
既然无缘
既然无缘 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:21

    try running this in your shell script:-

    pgrep mongod

    If the value is numeric you know that the process is running, if you get an empty value, flag it as service not running...

提交回复
热议问题