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
相关推荐
学涯乐码堂主2 小时前
GESP C++ 四级第一章:再谈函数(上)
c++·青少年编程·gesp·四级·学漄乐码青少年编程培训
微露清风3 小时前
系统性学习C++-第九讲-list类
c++·学习·list
大佬,救命!!!3 小时前
C++多线程同步与互斥
开发语言·c++·学习笔记·多线程·互斥锁·同步与互斥·死锁和避免策略
散峰而望3 小时前
C++入门(一)(算法竞赛)
c语言·开发语言·c++·编辑器·github
C_Liu_4 小时前
13.C++:继承
开发语言·c++
凡同学。4 小时前
通信人C++自学
c++·应届生秋招·后端四件套
威桑4 小时前
C++ Linux 环境下内存泄露检测方式
linux·c++
报错小能手5 小时前
C++笔记(面向对象)RTTI操作符
开发语言·c++·笔记
GOATLong5 小时前
git使用
大数据·c语言·c++·git·elasticsearch
十五年专注C++开发6 小时前
Qt-Nice-Frameless-Window: 一个跨平台无边框窗口(Frameless Window)解决方案
开发语言·c++·qt