Created
July 24, 2016 09:35
-
-
Save mssobhan/fecaa427b263a1b6ae7e2a84f40ce873 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
SCRIPT=("mongod") | |
PID=$(ps aux | grep -v grep | grep $SCRIPT | awk '{print $2}') | |
if [[ -z "$PID" ]] | |
then | |
nohup /opt/mongo30/mongodb/bin/mongod --dbpath /var/lib/mongodb/ --storageEngine wiredTiger --port 27017 & | |
else | |
#kill -9 $PID | |
#sleep 17 | |
#sleep 40 | |
echo "Successfully killed '$PID' no process. " | |
PID=$(ps aux | grep -v grep | grep $SCRIPT | awk '{print $2}') | |
if [[ -z "$PID" ]] | |
then | |
nohup /opt/mongo30/mongodb/bin/mongod --dbpath /var/lib/mongodb/ --storageEngine wiredTiger --port 27017 & | |
fi | |
PID=$(ps aux | grep -v grep | grep $SCRIPT | awk '{print $2}') | |
echo "Successfully started '$SCRIPT' with process no '$PID'." | |
fi | |
exit | |
####RUN IT in crontab entry using | |
###*/2 * * * * root /bin/bash /home/mohua/mongo30restarter.sh >> /home/mohua/mongo_out.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment