rc.local开机启动不生效的办法 – 业余语言练习

rc.local开机启动不生效的办法

cd /etc/rc.d/
chmod +x rc.local
[root@115 rc.d]# systemctl status rc-local.service
○ rc-local.service – /etc/rc.d/rc.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled-runtime; vendor preset: disabl>
Active: inactive (dead)
Docs: man:systemd-rc-local-generator(8)

[root@115 rc.d]# systemctl enable rc-local.service
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.

Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit’s
.wants/ or .requires/ directory.
• A unit’s purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, …).
• In case of template units, the unit is meant to be enabled with some
instance name specified.
[root@115 rc.d]# systemctl start rc-local.service
[root@115 rc.d]# shutdown -r now
http://xx.xxx.x.xxx/

It works!

[root@115 ~]# systemctl status rc-local.service
● rc-local.service – /etc/rc.d/rc.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled-runtime; vendor preset: disabl>
Active: active (running) since Sun 2025-06-01 16:44:12 CST; 48s ago
Docs: man:systemd-rc-local-generator(8)
Process: 1566 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)
Tasks: 9 (limit: 149544)
Memory: 12.8M
CGroup: /system.slice/rc-local.service
├─ 1753 /usr/local/apache/bin/httpd -k start
├─ 1786 /usr/local/apache/bin/httpd -k start
├─ 1787 /usr/local/apache/bin/httpd -k start
├─ 1788 /usr/local/apache/bin/httpd -k start
├─ 1789 /usr/local/apache/bin/httpd -k start

Published
Categorized as web-php

Leave a comment

Your email address will not be published. Required fields are marked *