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
相关推荐
hetao17338371 小时前
校内场-提高组 ZYZSC-S-Round 4
c++·算法
stellanke2 小时前
Linux网络编程实战2:TCP Socket 基础与实践
linux·网络·c++
蒸蒸yyyyzwd2 小时前
机试和Redis学习笔记
c++·笔记·面试
tdtsmt3 小时前
2026年SMT贴片加工选型指南:天地通电子推荐参考
c++
一木 之林3 小时前
插件、MCP、Skill 的区别?
java·c++·人工智能
ShineWinsu4 小时前
对于MySQL:内置函数的解析
linux·数据库·c++·mysql·面试·函数·查询
程序猿编码6 小时前
纯C++轻量计算机视觉推理引擎:基于GGML的端侧CV模型部署技术全解析
开发语言·c++·计算机视觉·大模型·transformer
Tairitsu_H7 小时前
[C++] C++11新增构造:列表初始化和std::initializer_list
开发语言·c++·c++11·构造
hansang_IR7 小时前
【题解】P4456 [CQOI2018] 交错序列(矩阵乘法)
c++·线性代数·算法
光电笑映8 小时前
Linux 线程同步与互斥:锁的本质、条件变量与信号量的底层原理
linux·运维·服务器·开发语言·c++