侧边栏壁纸
  • 累计撰写 11 篇文章
  • 累计创建 3 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

ubuntu自启动

ziwiwiz
2023-11-13 / 0 评论 / 0 点赞 / 19 阅读 / 0 字

Create a service:

sudo vi /etc/systemd/system/rc-local.service

Add your code there:

[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

Create and make sure /etc/rc.local is executable and add this code inside it:

sudo chmod +x /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0

Enable the service:

sudo systemctl enable rc-local

Start service and check status:

sudo systemctl start rc-local.service
sudo systemctl status rc-local.service

0
  1. 微信打赏

    qrcode weixin
    1. 微信打赏

      qrcode weixin

评论区