博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
debian9 开启rc.local服务
阅读量:6709 次
发布时间:2019-06-25

本文共 2235 字,大约阅读时间需要 7 分钟。

由于某些软件并没有增加开启启动的服务,很多时候需要手工添加,一般我们都是推荐添加命令到 /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 <
/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 前面即可,并尝试重启以后试试是否生效了

转载于:https://www.cnblogs.com/phpk/p/10514774.html

你可能感兴趣的文章
什么是并发用户数?并发用户数怎么计算?
查看>>
1、Linux基础认识
查看>>
Git在Githib和Github上的使用
查看>>
visual studio 编辑窗口 设置固定选项卡 使窗口选项卡多行显示
查看>>
处在LV1太长了··
查看>>
软件工程综合实践阶段小结
查看>>
文件操作的其他模式
查看>>
链表与顺序表的对比
查看>>
Angularjs总结(七) 路由及请求服务等
查看>>
Bindservice开启服务特点
查看>>
centos session
查看>>
Google Code Jam 2014 资格赛:Problem D. Deceitful War
查看>>
上传文件
查看>>
noip rp++
查看>>
js中数组的合并和对象的合并
查看>>
解决 UE4 无法找到。generated.h 办法
查看>>
python 读取SQLServer数据插入到MongoDB数据库中
查看>>
TCP的三次握手与四次挥手(详解+动图)
查看>>
Centos 6.5 磁盘修复 破解删除root密码
查看>>
某游戏浏览器Flash加速dll调用,打造我们自己的Flash加速器
查看>>