Linux 新增rc.local 開機啟動腳本

確認系統是否使用rc.local

systemctl status rc-local.service

建立rc.local服務

編輯/etc/systemd/system/rc-local.service

[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

創建文件rc.local,/etc/rc.local

#!/bin/sh -e
指令放入這
exit 0
chmod +x /etc/rc.local

啟用服務

systemctl enable rc-local
systemctl start rc-local
systemctl status rc-local

 

 


Revision #1
Created 18 July 2025 03:27:34 by Jason
Updated 18 July 2025 03:33:54 by Jason