在工作中,有时候需要把自己编写的启动服务脚本设置成开启自启动。
把脚本设置成开机自启动步骤如下
1、这个启动脚本必须能 用传参 start、stop、restart、等进行启动/关闭/重启等
2、这个脚本放在/etc/init.d/目录下
3、在脚本的#/bin/sh 下添加“# chkconfig、”和“# description:”
例如:
# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 64 36
# description: A very fast and reliable SQL database engine.
其中上面的chkconfig 和 description是必须的
其中上面64是开机(start)启动的顺序,36是关机前停止(stop)服务的顺序,而2345是指可以在--level中的2/3/4/5级别自动启动
上面的数字,以及描述内容根据具体情况,具体设置
4、上面步骤完成之后再在命令行中执行下面命令
#chkconfig --add servicename
#chkconfig servicename on
或者
#chkconfig --level 345 servicename on 即可
查看
#chkconfig --list servicename
转载于:https://blog.51cto.com/lvnian/1701264