Today study MongoDB, build time found that the source package did not provide a startup script, it was handy to write a convenient use.
[[email protected] mongodb]# cat /etc/init.d/mongodb #!/bin/bash# author: Baishaohua# mongodb boot shellmgdb_path= "/usr/local/mongodb" mgdb_conf= "${MGDB_PATH}/etc/ Mongodb.conf "Cd ${mgdb_path}mgdb_start () { if [ ' ps -ef|grep ' mongod -f ' |grep -v grep|wc -l ' > 0 ];then echo " Mongodb already start " exit 1 fi${mgdb_path}/bin/mongod -f ${MGDB_CONF}if [ $? -eq 0 ];thenecho -n "Mongodb start "echo -n " ["echo -ne " \033[32m "echo -n " successful "echo -ne " \e[ 0m "echo "] "Elseecho "mongodb start failed" Fi}mgdb_stop () { ${mgdb _path}/bin/mongod -f ${mgdb_conf} --shutdown if [ $? -eq 0 ];then echo -n "mongodb stop " echo -n "[" echo -ne "\033[ 32m " echo -n "Successful" echo -ne "\e[0m" echo "]" else echo "Mongodb stop failed" fi}mgdb_status () {ps -ef|grep ' mongod -f ' |grep -v grep if [ $? != 0 ];thenecho "Mongodb is stop" fi}case "$" in start) Mgdb_start;; stop) mgdb_stop;; status) Mgdb_status;; Restart) mgdb_stop MGDB_START;; *) echo $ "USAGE: $0 { START | STOP | STATUS | RESTART }" Exit 1esac
This article is from the "Nginxs Small white" blog, please be sure to keep this source http://nginxs.blog.51cto.com/4676810/1695505
MongoDB startup script