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
相关推荐
2501_941111242 小时前
C++与自动驾驶系统
开发语言·c++·算法
2501_941111692 小时前
C++中的枚举类高级用法
开发语言·c++·算法
旭编2 小时前
小红的好矩形
c++·算法
2501_941111463 小时前
C++与硬件交互编程
开发语言·c++·算法
夜晚中的人海4 小时前
【C++】哈希表算法习题
c++·算法·散列表
水木姚姚4 小时前
初识C++
开发语言·c++
权泽谦4 小时前
新世代的 C++:当 ChatGPT 遇上模板元编程
开发语言·c++·chatgpt
2501_941111404 小时前
C++中的状态模式实战
开发语言·c++·算法
鑫—萍5 小时前
C/C++精品算法——双指针(1)
c语言·c++·算法
2501_941111896 小时前
低延迟系统C++优化
开发语言·c++·算法