apiv1

rc.local 开机执行命令

  1. 添加文件

/lib/systemd/system/rc-local.service.d/rc-local.service

[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=infinity
RemainAfterExit=yes
GuessMainPID=no

[Install]
WantedBy=multi-user.target
Alias=rc-local.service
  1. 配置
    chmod +x /lib/systemd/system/rc-local.service.d/rc-local.service
    ln -s /lib/systemd/system/rc-local.service.d/rc-local.service /etc/systemd/system/
    
  2. rc.local

/etc/rc.local

#!/bin/sh

exit 0

可执行权限

chmod +x /etc/rc.local