ubuntu rc.local开机自启动

https://blog.csdn.net/qq_48974566/article/details/137212295

复制代码
sudo vim /lib/systemd/system/rc-local.service

#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
[Install]
WantedBy=multi-user.target

#!/bin/sh

bash /home/robot/multi-lidar-perception/perception_start.sh 2>&1 >>/home/robot/test/test1.log &
return 0

启动服务

复制代码
systemctl start rc-local.service

重启服务

复制代码
systemctl restart rc-local 

停止服务

复制代码
systemctl stop rc-local.service

rc.local 服务使能 --> 开机依旧生效

复制代码
systemctl enable rc-local.service

rc.local 禁用服务 --> 再次开机时会失效

复制代码
systemctl disable rc-local.service
相关推荐
ShineWinsu8 分钟前
对于Redis:List类型的解析
数据库·c++·redis·链表·缓存·面试·list
小师兄吃牛肉1 小时前
C++ 与 Lua 的协程交互:从原理到实战
c++·lua·交互
YYYing.1 小时前
【设计模式系列 (八) 】组合模式
c++·后端·设计模式·组合模式·c/c++
艾莉丝努力练剑1 小时前
【QT】系统相关:多线程QThread基础
开发语言·网络·c++·qt·学习·大模型
l1t2 小时前
DeepSeek总结的PIVCO-Huffman编码性能优化
数据结构·c++·算法
王维同学2 小时前
ETW监控-KswordARK功能展示
c++·windows·安全
東隅已逝,桑榆非晚2 小时前
c++模板进阶
开发语言·c++·笔记·学习
左手の明天11 小时前
SLIP 协议封装与解析详解:原理、C 代码与实战案例
linux·c语言·开发语言·c++
青少儿编程课堂11 小时前
后缀自动机解析:本质不同子串与最长重复片段统计
c++·python·算法·bfs·信息学竞赛