Debian 9.x “stretch” 解决 /etc/rc.local 开机启动问题
2018-01-02 11:24
429 查看
由于某些软件并没有增加开启启动的服务,很多时候需要手工添加,一般我们都是推荐添加命令到
并且默认情况下这个服务还是关闭的状态
为了解决这个问题,我们需要手工添加一个
然后赋予权限
接着启动
再次查看状态
然后你就可以把需要开机启动的命令添加到
/etc/rc.local文件,但是 Debian 9 默认不带
/etc/rc.local文件,而
rc.local服务却还是自带的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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 |
1 2 3 4 5 6 7 | 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文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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 |
1 2 | chmod +x /etc/rc.local |
rc-local服务
1 2 | systemctl start rc-local |
1 2 3 4 5 6 7 8 9 10 11 | 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-proxy systemd[1]: Starting /etc/rc.local Compatibility... Aug 03 09:41:18 xtom-proxy systemd[1]: Started /etc/rc.local Compatibility. |
/etc/rc.local文件,丢在
exit 0前面即可,并尝试重启以后试试是否生效了
相关文章推荐
- 解决centos7 开机/etc/rc.local 不执行的问题
- 解决centos7 开机/etc/rc.local 不执行的问题
- 解决centos7 开机/etc/rc.local 不执行的问题
- 解决centos7 开机/etc/rc.local 不执行的问题
- 开机启动/etc/rc.local失效无效怎么办?解决方法
- centos 7 /etc/rc.local 开机不执行的问题
- 普通用户开机启动服务/etc/rc.local
- 开机启动服务chkconfig开机启动脚本/etc/rc.local
- 关于自定义脚本rc.local里开机不启动的问题--以tomcat和perl相关的脚本为例
- centos7 开机/etc/rc.local 不执行的问题
- Centos 7关于rc.local脚本命令开机不执行及指定用户启动的解决方法
- centos 7.1开机/etc/rc.local脚本不执行的问题
- 通过进入单用户模式解决linux中的rc.local修改后无法启动的问题
- Ubuntu 16.04出现:"Failed to start /etc/rc.local Compatibility"的问题解决思路
- centos7 开机自启动 /etc/rc.local 不执行的问题
- centos7 开机/etc/rc.local 不执行的问题及部分命令执行不成功
- 关于自定义脚本rc.local里开机不启动的问题--以tomcat和perl相关的脚本为例
- centos7 开机/etc/rc.local 不执行的问题
- centos 7 /etc/rc.local 开机不执行的问题
- 【Linux】centOS 7 中 rc.local 文件开机不启动问题