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. ...
随机推荐
- WebSocketTest 异步通讯,实时返回数据
using System;using System.Net;using System.Net.Sockets;using System.Text;using System.Threading;usin ...
- Java的动手动脑(七)
日期:2018.11.18 博客期:025 星期日 Part 1:使用 Files.walkFileTree()来找出指定文件夹下大小大于1KB的文件 package temp; import jav ...
- MySql在windows上的安装
知乎安装教程 csdn安装教程 一.官网下载 ZIP Archive 内的软件包,mysql-xxx-win64.zip. 二.新建 MySQL 文件夹,解压缩下载包,进入文件夹(mysql-8.0. ...
- Linux之man命令详解及中文汉化
使用方法 Linux man中的man就是manual的缩写,用来查看系统中自带的各种参考手册 使用方法: man command 示例: [root@VM_0_13_centos ~]# man l ...
- 登录界面之Axure原型制作
*****登录界面制作步骤***** 1.背景色:需要设定的背景色不知道色值,可以使用截图工具截取一小块粘贴到axure页面, 点击页面样式中的背景色左上角的取色器点击一下该色块,即可将背景色全部填充 ...
- Jmeter 传值对比
${XXX}----------------------->在同一线程内可任务调用变量: vars.put(row,rowNum); ----------------------->var ...
- windows客户端走代理上网
前提:在大型网络中,由于众多服务器及安全性考虑,内网服务器是不能上外网的,但是为了满足某些服务的需要,一定会搭建代理服务器的. 以下是windows客户端走代理服务器的操作: 两下确定就可 ...
- JavaScript编程语言
JavaScript编程语言 JavaScript是一门编程语言,浏览器内置了JavaScript语言的解释器,所以在浏览器上按照JavaScript语言的规则编写相应代码之,浏览器可以解释并做出相应 ...
- 【C++ Primer | 03】字符串、向量和数组
博客链接: c++ 中 const_iterator 和 const vector<>::iterator的区别 const vector <int> ::iterator和v ...
- Windows配置Apache服务器
下载的Apache版本:httpd-2.4.32-o102n-x64-vc14 简单粗暴式配置: 1.打开\conf\httpd.conf修改第60行和第224行,其中8081是电脑上没有被使用的端口 ...