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
相关推荐
小欣加油22 分钟前
leetcode 329 矩阵中的最长递增路径
c++·算法·leetcode·矩阵·深度优先·剪枝
_给我学起来36 分钟前
字符数组和字符串
c++
骁的小小站1 小时前
Learn C the Hardway学习笔记和拓展知识(一)
c语言·开发语言·c++·经验分享·笔记·学习·bash
仰泳的熊猫1 小时前
LeetCode:700. 二叉搜索树中的搜索
数据结构·c++·算法·leetcode
楼田莉子2 小时前
C++学习:异常及其处理
开发语言·c++·学习·visual studio
杰 .2 小时前
C++ Hash
数据结构·c++·哈希算法
GHL2842710902 小时前
用PDH库获取CPU使用率(源码)
c++
让我们一起加油好吗2 小时前
【基础算法】多源 BFS
c++·算法·bfs·宽度优先·多源bfs
冷崖2 小时前
定时器的学习(二)
linux·c++·学习
大胆飞猪2 小时前
高并发内存池日志
c++·项目