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
相关推荐
stolentime2 分钟前
SOS DP学习笔记
c++·笔记·学习·算法·贪心算法·动态规划·二进制
用户76241175670527 分钟前
第四章 流程控制结构
c++
会编程的小孩1 小时前
Qt学习路线大纲图
c++
洁洁!1 小时前
手搓 C++ 线程池详细讲解以及如何面试应答
java·c++·面试
坤坤子吖2 小时前
C++继承:继承的基本用法与访问规则
开发语言·c++·笔记·学习
Demon--hx2 小时前
C++ 文件流:理解 ifstream/ofstream 与 RAII 机制
开发语言·c++
纪念 2292 小时前
C++ stack和queue
开发语言·c++
CodeYp20192 小时前
第6讲:模板初阶
开发语言·c++·模板
.YM.Z2 小时前
【C++11】初识——右值引用和移动语义,可变参数模板
c++·c++11
要练八块腹肌3 小时前
红黑树的实现以及对map和set的封装
c++