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
相关推荐
一拳一个呆瓜3 小时前
【STL】iostream 编程:使用提取运算符
c++·stl
我不是懒洋洋3 小时前
从零实现一个分布式日志平台:ELK的核心设计
c++
神仙别闹4 小时前
基于QT(C++)实现Windows 自启动项查看和分析
c++·windows·qt
WWTYYDS_6664 小时前
ProtoBuf超详细使用教程
c++
野生风长4 小时前
c++类和对象(this指针,重载operator,习题总结)
java·开发语言·c++
雪的季节5 小时前
Python「假多态」与 C++「真多态」的核心区别
开发语言·c++
zmzb01035 小时前
C++课后习题训练记录Day166
开发语言·c++
皓月斯语5 小时前
程序设计语言的特点
开发语言·数据结构·c++
邪修king6 小时前
C++ 进阶终章:异常机制与智能指针全解 —— 从错误处理到 RAII 资源管理,打通现代 C++ 的核心命脉
android·数据结构·c++
梓䈑11 小时前
【算法题攻略】BFS 解决FloodFill 算法、最短路问题、多源BFS 和 拓扑排序
c++·算法·宽度优先