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
相关推荐
Je1lyfish4 小时前
CMU15-445 (2025 Fall/2026 Spring) Project#3 - QueryExecution
linux·c语言·开发语言·数据结构·数据库·c++·算法
Brilliantwxx5 小时前
【C++】 vector(代码实现+坑点讲解)
开发语言·c++·笔记·算法
叼烟扛炮6 小时前
C++第三讲:类和对象(中)
开发语言·c++·类和对象
KuaCpp6 小时前
C++新特性学习
c++·学习
墨染千千秋6 小时前
C/C++ Keywords
c语言·c++
ximu_polaris6 小时前
设计模式(C++)-行为型模式-中介者模式
c++·设计模式·中介者模式
CSCN新手听安8 小时前
【Qt】Qt窗口(八)QFontDialog字体对话框,QInputDialog输入对话框的使用,小结
开发语言·c++·qt
tumu_C8 小时前
用std::function减缓C++模板代码膨胀和编译压力的一个场景
开发语言·c++
Hical619 小时前
C++17 实战心得:那些真正改变我写代码方式的特性
c++
Hical6110 小时前
实测:C++20 协程 vs Go Gin vs Rust Actix,谁的 Web 性能更强?
c++