当前位置:   article > 正文

ubuntu rc.local开机自启动

ubuntu rc.local开机自启动

https://blog.csdn.net/qq_48974566/article/details/137212295

sudo vim /lib/systemd/system/rc-local.service
  • 1
#  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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
#!/bin/sh

bash /home/robot/multi-lidar-perception/perception_start.sh 2>&1 >>/home/robot/test/test1.log &
return 0
  • 1
  • 2
  • 3
  • 4

启动服务

systemctl start rc-local.service
  • 1

重启服务

systemctl restart rc-local 
  • 1

停止服务

systemctl stop rc-local.service
  • 1

rc.local 服务使能 --> 开机依旧生效

systemctl enable rc-local.service
  • 1

rc.local 禁用服务 --> 再次开机时会失效

systemctl disable rc-local.service
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/803062
推荐阅读
相关标签
  

闽ICP备14008679号