感谢支持
我们一直在努力

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

更多Fedora相关信息见Fedora 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=5

本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-04/116320.htm

赞(0) 打赏
转载请注明出处:服务器评测 » Fedora 21 设置开机启动脚本
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏