11
2025
04
14:20:02

ubuntu 开启rc.local

1、创建rc.local.service服务的软链接

ln -s /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service
touch /etc/rc.local
chmod +x /etc/rc.local

2、修改  /etc/rc.local

#!/bin/bash
 
#你的命令,不要有死循环或无法退出的程序,不然进不了系统
#mount -t 9p -o trans=virtio hostshare /mnt/share
 
exit 0

3、直接执行生效

/etc/rc.local start

4、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=0RemainAfterExit=yes
GuessMainPID=no




推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

本文链接:https://hqyman.cn/post/10430.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: