#!/bin/bash mongod_start(){ /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf } mongod_stop(){ /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf --shutdown } case "$1" in start) echo start... mongod_start if [ $? == 0 ];then echo "Success start MongoDB!" fi ;; stop) mongod_stop if [ $? == 0 ];then echo "MongoDB is shutdown now !" fi ;; restart) mongod_stop mongod_start ;; *) echo "Use args (start|stop|restart)" ;; esac
乐享:知识积累,快乐无限。