Ubuntu server 开机服务不启动,服务无法自启动

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

启动模板配置

https://mp.csdn.net/editor/html/110097791

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值