最近新装了一台Fedora 30系统,服务已经正常运行起来了,但是偶然发现当我的系统重启后,写在rc.local配置文件里的命令居然没生效,导致我系统重启,但是服务却没有正常运行,后来经过一番查阅发现原来Fedora配置开机自启和CentOS存在一些区别,特此记录。

增加rc.local配置文件

vim /etc/rc.d/rc.local

#!/bin/bash
nohup /root/frp/frpc -c /root/frp/frpc.ini &
aria2c --conf-path=/root/Aria2/Aria2.conf -D

  Fedora和CentOS的区别:

  • CentOS本身存在/etc/rc.local配置文件,可以直接再此增加内容
  • CentOS配置文件中无须增加#!/bin/bash字头

在rc-local.service中添加Install字段

vim /lib/systemd/system/rc-local.service

[Unit]
Description=/etc/rc.d/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target [Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no [Install]
WantedBy=multi-user.target

  如果不存在Install字段可能在设置rc-local服务开机自启时出现如下报错:

    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:
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, ...).
4) In case of template units, the unit is meant to be enabled with some
instance name specified.

授权文件并启动设置开机自启

chmod +x /etc/rc.d/rc.local

systemctl enable rc-local.service

systemctl start rc-local.service

systemctl status rc-local.service

Fedora增加rc-local服务开机自启项的更多相关文章

  1. debian9 开启rc.local服务

    由于某些软件并没有增加开启启动的服务,很多时候需要手工添加,一般我们都是推荐添加命令到 /etc/rc.local 文件,但是 Debian 9 默认不带 /etc/rc.local 文件,而 rc. ...

  2. linux Nginx服务开机自启

    linux Nginx服务开机自启 Nginx 是一个很强大的高性能Web和反向代理服务器.虽然使用命令行可以对nginx进行各种操作,比如启动等,但是还是根据不太方便.下面介绍在linux下安装后, ...

  3. CentOS配置服务开机自启

    本例子以nginx作为举例: CentOS7中 以systemctl 替代了chkconfig 进行服务的管理, 默认在CentOS6 中控制服务开机自启,是在vim /etc/rc.d/rc.loc ...

  4. Linux 7开机自启项查看并设置

      在Linux6中查看及设置开机自启信息是使用chkconfig命令,Linux7中此命令已经被替代,接下来我们就来研究下Linux7中的区别所在. chkconfig --list Note: T ...

  5. 通过/etc/rc.local实现开机自动拉起服务

    添加服务到/etc/rc.local 如自动拉起apache服务: /etc/rc.local: #!/bin/sh # # This script will be executed *after* ...

  6. linux下三种服务开机自启的方式

    方式一.二.三适用于ubuntu,centos推荐使用方式二.方式三 方式一 在ubuntu系统中,如果你使用的apt方式安装的软件,可以使用如下方式直接添加服务的开机自启, 如果你是手动解压缩官网下 ...

  7. 在Linux环境下设置ArcGIS Server 服务开机自启

    在 VMware 11.0 中安装了CentOS 6.5的Linux系统中部署ArcGIS Server,安装完后默认开机不自动启动此服务,每次开机都要手动启动(如下图所示),这样太麻烦.本文记录了设 ...

  8. Mac下用Launchd实现使用rc.local执行开机启动命令

    其实原理很简单,使用Launchd创建一个开机启动的服务,然后这个服务关联/etc/rc.local文件,那么接下来操作rc.local就和Linux下一样的了. 当然,这种思路还可以直接使用在~/. ...

  9. Ubuntu 18.04 启用 rc.local 设置开机启动

    ubuntu18.04 不再使用initd管理系统,改用systemd. 然而systemd很难用,改变太大,跟之前的完全不同. 使用systemd设置开机启动为了像以前一样,在/etc/rc.loc ...

随机推荐

  1. Codeforces Round #573 (Div. 2) Tokitsukaze and Mahjong 水题

    B. Tokitsukaze and Mahjong time limit per test1 second memory limit per test256 megabytes Tokitsukaz ...

  2. Paper | Non-Local ConvLSTM for Video Compression Artifact Reduction

    目录 1. 方法 1.1 框图 1.2 NL流程 1.3 加速版NL 2. 实验 3. 总结 [这是MFQE 2.0的第一篇引用,也是博主学术生涯的第一篇引用.最重要的是,这篇文章确实抓住了MFQE方 ...

  3. 一、SqlServer查询今天的数据-多写法对比性能问题

    -- 目标:查询当天的所有数据 -- 说明:表数据行数:960w --方法一:使用格式化被查询条件与格式化当前时间比对 ),)),) --方法二:使用函数DATEDIFF 比对 --方法三:使用传统比 ...

  4. Debug 路漫漫-13:Python: pandas IndexError: single positional indexer is out-of-bounds

    在数据预处理过程中,出现:IndexError: single positional indexer is out-of-bounds 原因是在使用 Pandas 读取 dataframe 的时候,分 ...

  5. Ubuntu 16.04上anaconda安装和使用教程,安装jupyter扩展等 | anaconda tutorial on ubuntu 16.04

    本文首发于个人博客https://kezunlin.me/post/23014ca5/,欢迎阅读最新内容! anaconda tutorial on ubuntu 16.04 Guide versio ...

  6. JVM的监控工具之jvisual

    VisualVM(All-in-One Java Trouble shootingTool)是到目前为止随JDK发布的功能最强大的运行监视和故障处理程序,并且可以预见在未来一段时间内都是官方主力发展的 ...

  7. Node.js能解决什么问题?

    一.使用Node.js能解决什么问题 对于PHP.JAVA.Python等服务端语言中,为每个客户端连接创建一个新的线程,而每个线程需要大约2M的内存,理论上,具有8GB内存的服务器可以同时连接的最大 ...

  8. C# winform 获取鼠标点击位置

    说明:该篇随笔的代码内容并非出自本人,是在其他网站搜寻的,出处已经不记得了,本次随笔只为记录,目的帮助自己,帮助他人. 实现的原理也不做多的赘述,直接上代码. 第一个类是需要用到的Windows AP ...

  9. C# winform打开新窗体显示一段时间 关闭新窗体

    1.form1的button事件下: form2 form = new form2(); form.Show(); Thread.Sleep(10000);  //form2窗体显示10秒 form. ...

  10. Python struct与小端存储

    参考链接:https://www.liaoxuefeng.com/wiki/1016959663602400/1017685387246080 在使用Python 实现字符向字节数据类型转换的时候,P ...