Linux 自定义RPM启动脚本

cd /etc/rc.d/init.d

vim startShell

#!/usr/bin/env bash

#startShell

# chkconfig:   2345 80 20
# description: Starts and stops a single startShell instance on this system


case $1 in
        start)

            echo 'my test starting!!'
           ;;
        stop)
            echo 'my test stop!!'
            ;;
         restart)
            echo 'my test restart'
            ;;
         *)
            echo 'params err'
            ;;
esac

chmod 777 startShell

cp startShell /etc/rc.d/init.d

service startShell on  #开启脚本

脚本中加入以下注释   2345 为注释头  80代表启动的顺序 一半应该靠后开启  20代表结束  关机时应早点结束

# chkconfig:   2345 80 20
# description: Starts and stops a single startShell instance on this system

加入保存

chkconfig --list startShell  #核对启动中是否含有startShell的启动脚本

chkconfig startShell on #开启对startShell的启动脚本

chkconfig startShell off #关闭对startShell的启动脚本


 

发布了74 篇原创文章 · 获赞 15 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/zb313982521/article/details/88142644