[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
直接在/etc/sysconfig/network-scripts/ifcfg-<name> 的最后写上你要执行的脚本即可
这似乎并不能保证在网卡成功启动后才能执行,也就是只要你尝试启动网卡,这里的命令都会执行,因此你可以尝试写入判断网卡已经成功启动的脚本
我的是fedora发行版本,提供参考:
设置开机启动:
sudo systemctl enable rc-local.service
如果出现以下错误提示: