2021-05-12 14:32:11
Fedora 21 設定開機啟動指令碼
Fedora 21 設定開機啟動指令碼
sudo touch /etc/rc.d/rc.local
sudo vim /etc/rc.d/rc.local
在/etc/rc.d/rc.local檔案中寫入, 然後使用:wq命令 儲存並退出.
#!/bin/bash
# 在這個檔案中寫入開機啟動需要執行的命令
賦予可執行許可權:
sudo chmod+x /etc/rc.d/rc.local
設定開機啟動:
sudo systemctl enable rc-local.service
如果出現以下錯誤提示:
[root@dev-zhanghua ~]# systemctl enable rc-local.service
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
sudo vim /usr/lib/systemd/system/rc-local.service
在rc-local.service檔案末尾加入:
[Install]
WantedBy=multi-user.target
並重新設定開機啟動:
sudo systemctl enable rc-local.service
檢視狀態, 如果出現以下提示, 設定成功!
[zhanghua@dev-zhanghua ~]$ systemctl status rc-local.service
● rc-local.service - /etc/rc.d/rc.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled)
Active: active (running) since Wed 2015-04-15 11:37:40 CST; 1h 44min ago
相關文章