[Email protected] local]# Cat/etc/init.d/mongod
#!/bin/sh
# # chkconfig:2345 65 38
Source/etc/profile
Config=/usr/local/mongodb/mongod.cnf
Program=/usr/local/mongodb/bin/mongod
Mongopid= ' Ps-ef | grep ' Mongod--config ' | Grep-v grep | awk ' {print $} '
Test-x $PROGRAM | | Exit 0
Case "$" in
Start
echo "Starting MongoDB Server ..."
$PROGRAM--config $CONFIG &
;;
Stop
echo "Stopping MongoDB Server ..."
if [!-Z "$MONGOPID"]; Then
Kill-15 $MONGOPID
Fi
;;
Status
If [-Z "$MONGOPID"]; Then
echo "MongoDB is not running!"
Else
echo "MongoDB is running! ("$MONGOPID") "
Fi
;;
Restart
echo "shutting down MongoDB Server ..."
if [!-Z "$MONGOPID"]; Then
Kill-15 $MONGOPID
Fi
echo "Starting MongoDB ..."
$PROGRAM--config $CONFIG &
;;
*)
Log_success_msg "Usage:/etc/init.d/mongod {Start|stop|status|restart}"
Exit 1
Esac
Exit 0
MongoDB configuration file:
[Email protected] local]# CAT/USR/LOCAL/MONGODB/MONGOD.CNF
Logpath=/usr/local/mongodb/logs/log
Logappend = True
#fork and run in background
Fork = True
#port = 27017
Dbpath=/usr/local/mongodb/data
#location of Pidfile
Pidfilepath=/usr/local/mongodb/mongod.pid
Auth = True
This article is from the "10931853" blog, please be sure to keep this source http://wujianwei.blog.51cto.com/10931853/1962577
MongoDB startup script