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
相关推荐
Ljw...17 分钟前
DeepSeek+Kimi生成高质量PPT
数据库·c++·powerpoint·ppt·deepseek
敲上瘾18 分钟前
基础dp——动态规划
java·数据结构·c++·python·算法·线性回归·动态规划
禁默1 小时前
C++之旅-C++11的深度剖析(1)
开发语言·c++
张有志_1 小时前
STL容器终极解剖:C++ vector源码级实现指南 | 从内存分配到异常安全的全流程避坑
c语言·c++·算法·开源·visual studio
挨代码1 小时前
UE_C++ —— Delegates
c++·ue
web_155342746563 小时前
性能巅峰对决:Rust vs C++ —— 速度、安全与权衡的艺术
c++·算法·rust
9毫米的幻想3 小时前
【Linux系统】—— 冯诺依曼体系结构与操作系统初理解
linux·运维·服务器·c语言·c++
Mr.Wang8093 小时前
条款23:宁以non-member、non-friend替换member函数
开发语言·c++
以卿a4 小时前
C++ 模板初阶
开发语言·c++
黑不溜秋的10 小时前
C++ 设计模式 - 策略模式
c++·设计模式·策略模式