事故现场
在 ubuntu-18.04.3 版本中,使用 chkconfig 命令报错:
chkconfig –list
chkconfig: command not found
这段文本似乎是一个命令提示符,试图执行 chkconfig --list 命令,但返回了一个错误信息“chkconfig:command not found”。这个错误信息表明系统上没有安装 chkconfig 实用程序,或者它没有包含在系统的 PATH 变量中。
问题原因
Ubuntu 中 chkconfig 已经被 sysv-rc-conf 所替代;
解决方案
apt-get update
apt-get install sysv-rc-conf
sysv-rc-conf –list
通过 sysv-rc-conf 命令设置:
- 在
/etc/init.d里面建立一个test.sh(启动文件前面务必添加如下三行代码,否侧会提示sysv-rc-conf不支持):
#!/bin/bash 选择Shell 环境
# chkconfig: 2345 55 25 #宝塔脚本中自动添加的并且测试能正常运行的
###sysv-rc-conf: 35 20 80 分别代表运行级别,启动优先权,关闭优先权
#description: test server 描述一下脚本
- 内容如下:
#!/bin/bash
# chkconfig: 2345 55 25
###sysv-rc-conf: 35 20 80
#description: test server
cd /root/test
bash start.sh
- 增加脚本的可执行权限:
chmod +x /etc/init.d/test.sh
- 然后安装
sysv-rc-conf:
apt-get install sysv-rc-conf
- 添加脚本到开机自动启动项目中。添加到
sysv-rc-conf,开机自启动:
cd /etc/init.d
sysv-rc-conf –add test.sh
sysv-rc-conf test.sh on
- 关闭开机启动:
sysv-rc-conf test.sh off
- 从
sysv-rc-conf管理中删除test.sh:
sysv-rc-conf –del test.sh
- 查看
sysv-rc-conf管理:
sysv-rc-conf –list test.sh
欢迎指出任何有错误或不够清晰的表达,可以在下面评论区评论。