Skip to content

Instantly share code, notes, and snippets.

@4np
Created January 24, 2013 13:54
Show Gist options
  • Save 4np/4621850 to your computer and use it in GitHub Desktop.
Save 4np/4621850 to your computer and use it in GitHub Desktop.
two aliasses (mongostart and mongostop) to stop and start a mongoDB NOSQL store, installed using MacPorts
# mongo db
# see http://noteit.jiaeil.com/install-mongodb-via-macports-on-mac
alias mongostart="sudo nice mongod --rest -f /opt/local/etc/mongodb/mongod.conf; clear; tail -f /opt/local/var/log/mongodb/mongodb.log"
mongostop_func () {
# local mongopid=`ps -o pid,command -ax | grep mongod | awk '!/awk/ && !/grep/{print $1}'`;
# just find a simpler way
local mongopid=`less /opt/local/var/db/mongodb_data/mongod.lock`;
if [[ $mongopid =~ [[:digit:]] ]]; then
sudo kill -15 $mongopid;
echo mongod process $mongopid terminated;
else
echo mongo process $mongopid not exist;
fi
}
alias mongostop="mongostop_func"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment