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
相关推荐
chari克里20 小时前
QT5.15.2 + msvc2022部署全流程说明(windows可联网环境)
开发语言·c++·qt
码匠许师傅21 小时前
【C++三方组件】mbedTLS:面向嵌入式的轻量 TLS
开发语言·c++
?re?ta?rd?ed?1 天前
C++11新特性,{}与左值
c++·windows
j7~1 天前
【穷举、深搜与回溯算法】一棵决策树讲透全排列与子集
数据结构·c++·算法·leetcode·回溯·递归
kiracrimson1 天前
栈与队列容器:适配器、deque 与 priority_queue
开发语言·c++·适配器模式
qq_466302451 天前
如何通过部分文件名,读取出整个文件名
c++·qt
octopus_c1 天前
C++ 入门
开发语言·c++·算法
raindayinrain1 天前
c++新特性--实用新特性
c++
Soneswy1 天前
C++基础篇——类与对象(中)
开发语言·c++
kiracrimson1 天前
STL:List的使用和模拟实现
开发语言·c++·list