Friday, 3 June 2016

How to check MongoDB is running with linux shell script?


#!/bin/bash

if pgrep mongod >>/dev/null ;then
    echo "Mongo DB Server is Running"
else
    echo "Mongo DB Server is not Running"
fi


Explanation: pgrep is signal process, it looks through running process and list the process id' s that matches the name of the process.

No comments:

Post a Comment