[Note]Mac OS MongoDB 启动脚本
#!/bin/bash if [ -z $1 ] ; then echo "Usage: $0 [start|stop|restart] " exit 1 fi Source the common setup functions for startup scripts test -r /etc/rc.common || exit 1 . /etc/rc.common Set up some defaults DBPATH='/usr/local/mongodb/db' LO
#!/bin/bash
if [ -z $1 ] ; then
echo "Usage: $0 [start|stop|restart] "
exit 1
fi
Source the common setup functions for startup scripts
test -r /etc/rc.common || exit 1
. /etc/rc.common
Set up some defaults
DBPATH='/usr/local/mongodb/db'
LOGPATH='/usr/local/mongodb/log/mongod.log'
MONGOD_PORT=27017
StartService(){
/usr/local/mongodb/bin/mongod run --dbpath=$DBPATH --logpath=$LOGPATH --port $MONGOD_PORT > /dev/null 2>&1 &
}
StopService() {
pidfile=$DBPATH/mongod.lock
# If the lockfile exists, it contains the PID if [ -e $pidfile ]; then pid=`cat $pidfile` fi # If we don't have a PID, check for it if [ "$pid" == "" ]; then pid=`/usr/sbin/lsof -i tcp:$MONGOD_PORT | tail -1 | awk '{print $2}'` fi # If we've found a PID, let's kill it if [ "$pid" != "" ]; then kill -15 $pid fi
}
RestartService() {
StopService
sleep 3
StartService
}
RunService $1
原文地址:[Note]Mac OS MongoDB 启动脚本, 感谢原作者分享。
推荐阅读
-
MAC OS X Lion启动U盘制作和使用U盘安装系统图文教程
-
Linux下的mongodb服务监视脚本(启动服务)
-
Mac OS 自带apache 启动不了的问题
-
Mac OS X 设置取消开机自动启动的方法
-
mac os x快捷键中方说明(启动快捷键、Finder快捷键、鼠标键)
-
让Mac OS X系统启动时执行脚本的方法
-
在Mac OS上安装使用MongoDB的教程
-
Mac os下hadoop启动成功后显示unable to load native-hadoop library
-
MAC OS X Lion启动U盘制作和使用U盘安装系统图文教程
-
[Note]Mac OS MongoDB 启动脚本