LINUX设置自定义服务(centos6.6)

安装了一个amoeba,这个并不是系统服务,要设置开机启动,于是就去修改/etc/rc.local文件,用了绝对路径,在命令行下测试是可以成功启动的,但是开机不生效,于是想把这个设置成系统的服务,之前没做过,记录下
1.照格式写shell

vi /etc/init.d/amoeba
#!/bin/bash
#
# auditd        This starts and stops auditd
#
# chkconfig: 2345 11 88
# description: This starts the Linux Auditing System Daemon, \
#              which collects security related events in a dedicated \
#              audit log. If this daemon is turned off, audit events \
#              will be sent to syslog.
#
#
######forjava
export JAVA_HOME=/usr/java/jdk1.6.0_45
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
#######

###amoeba
export AMOEBA_HOME=/usr/local/amoeba/
export PATH=$PATH:$AMOEBA_HOME/bin
#######
case "$1" in
start)
        echo "Starting amoeba"
        /usr/local/amoeba/bin/amoeba start &
        ;;

stop)
        echo "Stop amoeba"
        /usr/local/amoeba/bin/amoeba stop
        ;;
restart)
        echo "Stop amoeba..."
        /usr/local/amoeba/bin/amoeba stop
        echo "Starting amoeba"
        /usr/local/amoeba/bin/amoeba start &
        ;;
esac

再配置

chmod +x amoeba #给权限
chkconfig --add amoeba #添加到系统服务

ok

你可能感兴趣的:(LINUX设置自定义服务(centos6.6))