Linux设置自启动
sysv-rc-conf — Linux设置开机自动启动
CentOS7 开机自启动脚本 chkconfig方式
通过sysv-rc-conf命令设置
1.在/etc/init.d 里面建立一个test.sh(启动文件前面务必添加如下三行代码,否侧会提示sysv-rc-conf不支持。
#!/bin/bash 选择Shell 环境
#sysv-rc-conf: 35 20 80 分别代表运行级别,启动优先权,关闭优先权
#description: test server 描述一下脚本
2.内容如下:
#!/bin/bash
#sysv-rc-conf: 35 20 80
#description: test server
cd /root/test
bash start.sh
3.增加脚本的可执行权限
chmod +x /etc/init.d/test.sh
4.然后安装sysv-rc-conf
apt-get install sysv-rc-conf
5.添加脚本到开机自动启动项目中。添加到sysv-rc-conf,开机自启动。
cd /etc/init.d
sysv-rc-conf --add test.sh
sysv-rc-conf test.sh on
6.关闭开机启动
sysv-rc-conf test.sh off
7.从sysv-rc-conf管理中删除test.sh
sysv-rc-conf --del test.sh
8.查看sysv-rc-conf管理
sysv-rc-conf --list test.sh