Ubuntu 版本:20.04.1 TLS
在 /lib/systemd/system/ , /etc/systemd/system/ 两个目录配置好服务关联后设置systemctl enable XXXX 服务成功。
重启服务器,服务未启动,排查结果:脚本未设置启动级别。
服务脚本模板:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
(此处插入启动级别内容)
(....)用户自定义要运行的代码
exit 0
启动级别模板:2 3 4 5 为开机机器运行的相关时段尝试启动服务
### BEGIN INIT INFO
# Provides: service_name
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description:
# Description:
### END INIT INFO
引用内容:
设置服务启动配置
https://blog.csdn.net/ErErFei/article/details/98205463
启动模板配置