/*******************************************************************************
* systemctl enable rc-local.service error
* 说明:
* 在YOCTO中使能rc.local发现无法enable;
*
* 2019-6-10 深圳 宝安西乡 曾剑锋
******************************************************************************/ 一、Error
root@zengjf:/etc/systemd/system# 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. 二、错误原因
. 无Install字段;
. 添加Install字段:
root@zengjf:/lib/systemd/system# cat rc-local.service
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version. # This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator()
ConditionFileIsExecutable=/etc/rc.local
After=network.target [Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=
RemainAfterExit=yes
GuessMainPID=no [Install]
WantedBy=multi-user.target
. 重新enable:
root@zengjf:/etc/systemd/system# systemctl enable rc-local.service
Created symlink /etc/systemd/system/multi-user.target.wants/rc-local.service → /lib/systemd/system/rc-local.service.
. 查看生成文件:
root@zengjf:/etc/systemd/system/multi-user.target.wants# ls -al rc-local.service
lrwxrwxrwx root root Apr : rc-local.service -> /lib/systemd/system/rc-local.service
root@zengjf:/etc/systemd/system/multi-user.target.wants#
. 创建/etc/rc.local,并赋予执行权限;
root@zengjf:~# cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
# echo "-------------------------------" >> /etc/zengjf
echo rc.local >> /etc/zengjf
echo "-------------------------------" >> /etc/zengjf exit
. 重启查看输出;
root@zengjf:~# cat /etc/zengjf
-------------------------------
rc.local
-------------------------------

systemctl enable rc-local.service error的更多相关文章

  1. 曹工改bug:centos下,mongodb开机不能自启动,systemctl、rc.local都试了,还是不行,要不要放弃?

    问题背景 最近装个centos 7.6的环境,其中,基础环境包括,redis.nginx.mongodb.fastdfs.mysql等,其中,自启动使用的是systemctl,其他几个组件,都没啥问题 ...

  2. Ubuntu 18.04 设置开机启动脚本 rc.local systemd

    ubuntu18.04不再使用initd管理系统,改用systemd. ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本,通过下列简单设置后,可以使rc.l ...

  3. debian9 开启rc.local服务

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

  4. Debian 9.x "stretch" 解决 /etc/rc.local 开机启动问题

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

  5. rc.local(ubuntu18.04)

    系统自带服务/lib/systemd/system/rc-local.service 软连接为 /lib/systemd/system/rc.local.service -> rc-local. ...

  6. Arch下systemd无法开机执行rc.local之解决方法

    早就发现了,Arch的systemd提供的那个 rc-local.service 貌似有问题,rc.local不会执行.因为没用rc.local,一直没管. 解决方法源自这里,需要稍加改动: http ...

  7. 没有rc.local的解决办法

    转载请注明来源https://www.cnblogs.com/sogeisetsu/p/11395098.html linux 开机自启动 我是小白,最近在想如何使用linux开机自启动,有一个办法是 ...

  8. centos7 /etc/rc.local需要chmod +x /etc/rc.d/rc.local

    Centos 7.0设置/etc/rc.local无效问题解决 安装centos7以后按照以往习惯修改rc.local添加开机启动命令,但重启后发现无效,再次重启发现依然如故 检查系统rc.local ...

  9. Centos 7.0设置/etc/rc.local无效问题解决

    安装centos7以后按照以往习惯修改rc.local添加开机启动命令,但重启后发现无效,再次重启发现依然如故 检查系统rc.local服务运行情况 systemctl | grep "rc ...

随机推荐

  1. Vue学习之过滤器和自定义指令小结(三)

    过滤器: 过滤是一个数据经过了这个过滤之后出来另一样东西,可以是从中取得你想要的,或者给那个数据添加点什么装饰.过滤器就是过滤用的工具.渲染数据用的!!! 我们需要知道的是: 1.Vue中的过滤器不能 ...

  2. Java 之 Object 类

    一.Object 概述  java.lang.Object 类是 Java 语言中的根类,即所有类的父类. 在对象实例化的时候,最终找的父类就是 Object. 如果一个类没有特别指定父类,那么默认则 ...

  3. BeanPostProcessor后置处理器原理以及ApplicationListener原理

    BeanPostProcessor:bean后置处理器,bean创建对象初始化前后进行拦截工作的 1.BeanFactoryPostProcessor:BeanFactory的后置处理器; 在Bean ...

  4. 【Maven】Maven中排除依赖、归类依赖、优化依赖

    参考博文:Maven中排除依赖.归类依赖.优化依赖

  5. AI的自学题库-竞赛-基础知识

    阿里云(天池): https://tianchi.aliyun.com/course?spm=5176.12281897.0.0.209439a9UwObn3 天池竞赛:https://tianchi ...

  6. linux设备驱动程序-i2c(2)-adapter和设备树的解析

    linux设备驱动程序-i2c(2)-adapter和设备树的解析 (注: 基于beagle bone green开发板,linux4.14内核版本) 在本系列linux内核i2c框架的前两篇,分别讲 ...

  7. mysql的binlog空间维护

    .Binlog空间维护 一,显示当前的logs文件记录 show master logs; 二,清空n天前的日志,减少磁盘空间 PURGE MASTER LOGS BEFORE DATE_SUB(CU ...

  8. springboot集成ftp

    目录 springboot集成ftp pom依赖包 ftp登录初始化 ftp上传文件 ftp读取文件,并转成base64 ftp下载文件 ftp客户端与服务端之间数据传输,主动模式和被动模式 spri ...

  9. javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.qingmu.Customer

    javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity pas ...

  10. 使用 Express Generator快速创建Express应用

    全局安装express-generator npm install express-generator -g 根据需求生成自己需要的模板 生成ejs模板:express demo --view=ejs ...