以启动mongodb为例
创建启动脚本start_mongodb.sh
#!/bin/bash
#chkconfig: 2345 80 90
#description:start_mongodb.sh
mongodb安装目录/bin/mongod --dbpath mongodb安装目录/data/db &
在/etc/rc.local增加启动命令
sudo vi /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
cd ~
./start_mongodb.sh
exit 0