debian9 开启rc.local服务
由于某些软件并没有增加开启启动的服务,很多时候需要手工添加,一般我们都是推荐添加命令到 /etc/rc.local
文件,但是 Debian 9 默认不带 /etc/rc.local
文件,而 rc.local
服务却还是自带的
root@debian9 ~ # cat /lib/systemd/system/rc.local.service # 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 ConditionFileIsExecutable=/etc/rc.local After=network.target [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 RemainAfterExit=yes GuessMainPID=no
并且默认情况下这个服务还是关闭的状态
root@debian9 ~ # systemctl status rc-local ● rc-local.service - /etc/rc.local Compatibility Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled) Drop-In: /lib/systemd/system/rc-local.service.d └─debian.conf Active: inactive (dead)
为了解决这个问题,我们需要手工添加一个 /etc/rc.local
文件
cat <<EOF >/etc/rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. exit 0 EOF
然后赋予权限
chmod +x /etc/rc.local
接着启动 rc-local
服务
systemctl start rc-local
再次查看状态
root@debian9 ~ # systemctl status rc-local ● rc-local.service - /etc/rc.local Compatibility Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled) Drop-In: /lib/systemd/system/rc-local.service.d └─debian.conf Active: active (exited) since Thu 2017-08-03 09:41:18 UTC; 14s ago Process: 20901 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS) Aug 03 09:41:18 xtom-hk systemd[1]: Starting /etc/rc.local Compatibility... Aug 03 09:41:18 xtom-hk systemd[1]: Started /etc/rc.local Compatibility.
然后你就可以把需要开机启动的命令添加到 /etc/rc.local
文件,丢在 exit 0
前面即可,并尝试重启以后试试是否生效了
debian9 开启rc.local服务的更多相关文章
- Debian 9.x "stretch" 解决 /etc/rc.local 开机启动问题
由于某些软件并没有增加开启启动的服务,很多时候需要手工添加,一般我们都是推荐添加命令到 /etc/rc.local 文件,但是 Debian 9 默认不带 /etc/rc.local 文件,而 rc. ...
- centos7 /etc/rc.local需要chmod +x /etc/rc.d/rc.local
Centos 7.0设置/etc/rc.local无效问题解决 安装centos7以后按照以往习惯修改rc.local添加开机启动命令,但重启后发现无效,再次重启发现依然如故 检查系统rc.local ...
- Centos 7.0设置/etc/rc.local无效问题解决
安装centos7以后按照以往习惯修改rc.local添加开机启动命令,但重启后发现无效,再次重启发现依然如故 检查系统rc.local服务运行情况 systemctl | grep "rc ...
- /etc/rc.d/rc.local linux启动自动开启某些服务(转)
/etc/rc.d/rc.local似乎是很多Linux系统管理员的偏爱,因为凡是需要随系统自动启动的服务.程序等,只要系统没有提供Sys V风格的启动脚本,就把这些需求都塞到/etc/rc.d/rc ...
- 通过/etc/rc.local实现开机自动拉起服务
添加服务到/etc/rc.local 如自动拉起apache服务: /etc/rc.local: #!/bin/sh # # This script will be executed *after* ...
- rc.local 开启自启动,检测是否成功
rc.local /etc/init.d/nginx start 查看运行状态 systemctl status rc-local ● rc-local.service - /etc/rc.local ...
- rc-local.service服务启动失败,导致rc.local中的开机启动服务不能启动
chmod +x /etc/rc.d/rc.local 打开/etc/rc.local文件,将启动非后台执行的指令的最后添加 &,以使相关指令后台运行,然后启动服务 systemctl ...
- Ubuntu 16.04设置rc.local开机启动命令/脚本的方法(通过update-rc.d管理Ubuntu开机启动程序/服务)
注意:rc.local脚本里面启动的用户默认为root权限. 一.rc.local脚本 rc.local脚本是一个Ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令.该脚本位于/et ...
- rc.local添加tomcat服务启动命令,但是tomcat服务无法正常启动
遇到了一个特别坑的问题. 本来想着在rc.local文件里添加tomcat启动命令,使tomcat开机自启.之前在其他服务器上直接这样操作是没问题的,但很幸运的是,现在忽然就不行了. 开始排错: 1. ...
随机推荐
- 【进阶3-4期】深度解析bind原理、使用场景及模拟实现(转)
这是我在公众号(高级前端进阶)看到的文章,现在做笔记 https://github.com/yygmind/blog/issues/23 bind() bind() 方法会创建一个新函数,当这个新函 ...
- swift 实践- 10 -- UIProgressView
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoa ...
- pytorch:修改预训练模型
torchvision中提供了很多训练好的模型,这些模型是在1000类,224*224的imagenet中训练得到的,很多时候不适合我们自己的数据,可以根据需要进行修改. 1.类别不同 # codin ...
- swoole 使用异步redis的前置条件
redis安装 官网下载redis 下载完成之后解压: 进入redis目录执行make: 进入src目录启动redis 启动成功如下: 启动后连接redis 编译安装hiredis 下载:https: ...
- Distance
1191: Distance 时间限制: 1 Sec 内存限制: 32 MB 题目描述 There is a battle field. It is a square with the side l ...
- 在vue项目中使用axios发送FormData
这个是axios的中文文档,挺详细的: https://www.kancloud.cn/luponu/axios/873153 文档中的 使用 application/x-www-form-ur ...
- AI-restful接口写法
AI-restful接口写法 restful接口规范 http协议请求方式:GET POST DELETE PUT PATCH OPTION HEAD 设计接口时必须使用这种格式的数据 GET 查看数 ...
- ActiveSync之HTTP
Exchange ActiveSync:HTTP协议让客户端能够同步存储在服务器上的数据. 互联网工程工作小组(IETF)要求所有互联网协议都比支持UTF-8编码.因此,ActiveSync传输所使用 ...
- 51 Nod 1242 斐波那契数列的第N项(矩阵快速幂模板题)
1242 斐波那契数列的第N项 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 斐波那契数列的定义如下: F(0) = 0 F(1) = 1 F(n) ...
- 【TensorFlow】基于ssd_mobilenet模型实现目标检测
最近工作的项目使用了TensorFlow中的目标检测技术,通过训练自己的样本集得到模型来识别游戏中的物体,在这里总结下. 本文介绍在Windows系统下,使用TensorFlow的object det ...