Debian 9.x "stretch" 解决 /etc/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
为了解决这个问题,我们需要手工添加一个 /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-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 前面即可,并尝试重启以后试试是否生效了
root@Samba96-21:/home/user# ls
images ServerStatus
root@Samba96-21:/home/user# cd ServerStatus/
root@Samba96-21:/home/user/ServerStatus# pwd
/home/user/ServerStatus
root@Samba96-21:/home/user# vim.tiny /etc/rc.local
/usr/bin/python3 /home/user/ServerStatus/ServerStatus.py &
exit 0
作者:吾星喵
链接:https://www.jianshu.com/p/8408d66942bf
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Debian 9.x "stretch" 解决 /etc/rc.local 开机启动问题的更多相关文章
- Ubuntu 16.04设置rc.local开机启动命令/脚本的方法
Ubuntu 16.04设置rc.local开机启动命令/脚本的方法 Ubuntu 16.04设置rc.local开机启动命令/脚本的方法(通过update-rc.d管理Ubuntu开机启 ...
- Ubuntu 16.04设置rc.local开机启动命令/脚本的方法(通过update-rc.d管理Ubuntu开机启动程序/服务)
注意:rc.local脚本里面启动的用户默认为root权限. 一.rc.local脚本 rc.local脚本是一个Ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令.该脚本位于/et ...
- (转)CentOS 7 —— /etc/rc.local 开机不执行 - 解决方法
chmod +x /etc/rc.d/rc.localsystemctl enable rc-local.service Note: rc.local is obsolete. ----------- ...
- 配置rc.local开机自启动文件的疑问
有时我们自己在/etc/rc.d/rc.local里面增加的随机器启动的脚本和指令总是不能自动加载和启动,,机器启动后手动执行脚本又能成功,经常被搞得晕头转向的.最近我经过1天的辛苦测试和查找资料,终 ...
- centos 7 /etc/rc.local 开机不执行的问题
最近发现centos7 的/etc/rc.local不会开机执行,于是认真看了下/etc/rc.local文件内容的就发现了问题的原因了 1 2 3 4 5 6 7 8 9 10 11 #!/bin/ ...
- centos7设置rc.local开机执行命令
在Centos7下,rc.local文件,开机默认是不执行的 它是个软链接 [root@data-1-1 ~]# ll /etc/rc.local lrwxrwxrwx. 1 root root 13 ...
- /etc/rc.d/rc.local linux启动自动开启某些服务(转)
/etc/rc.d/rc.local似乎是很多Linux系统管理员的偏爱,因为凡是需要随系统自动启动的服务.程序等,只要系统没有提供Sys V风格的启动脚本,就把这些需求都塞到/etc/rc.d/rc ...
- rc.local 开机自启脚本无法启动
1.看是否rc.local 第一行如果是 #!/bin/sh -e 改成 #!/bin/bash sudo systemctl enable rc-local.service 2.看rc.local的 ...
- CentOS7 rc.local开机开法启动
CentOS 7添加开机启动服务/脚本 一.添加开机自启服务 在CentOS 7中添加开机自启服务非常方便,只需要两条命令(以Jenkins为例):systemctl enable jenkins.s ...
随机推荐
- AS3.0 位图翻转、旋转
/* * * *-------------------------* * | *** 位图翻转.旋转 *** | * *-------------------------* * * 作 者:fengz ...
- Redis 如何与数据库事务保持一致
考虑一个问题,redis 如何 与 数据库保持一致性的问题. 举栗子:如果我们在开发过程中遇到这样的一种情况,我们删除 redis中token 的同时 也需要修改数据库中 储存的 token 的状态为 ...
- solr的post.jar
http://iamyida.iteye.com/blog/2207920 跟益达学Solr5之玩转post.jar
- template中实现加减乘除数学运算
django模板只提供了加法的filter,没有提供专门的乘法和除法运算:django提供了widthratio的tag用来计算比率,可以变相用于乘法和除法的计算. # 加法{{value|add:1 ...
- ElementUI对话框(dialog)提取为子组件
需求:在页面的代码太多,想把弹窗代码提取为子组件,复用也方便. 这里涉及到弹窗el-dialog的一个属性show-close: show-close="false"是设置不显 ...
- Linux下安装php开发环境
先记录下以恶搞教程,回头自己更 https://my.oschina.net/hhly/blog/1547227
- IDEA提示不区分大小写设置
File–>Settings–>Editor–>General–>Code Completion–>Mach case的勾取消掉就可以了 取消勾后效果如下
- javascript动态添加html节点
之前一直没怎么接触需要动态添加和删除html节点的项目,这次项目中用到了,也学习了. 在一个<table id="tab">标签中添加一个<tr id=" ...
- 初识Nginx,简单配置实现负载均衡(ubuntu + Nginx + tomcat)
工作需要,研究了一下Nginx的反向代理实现负载均衡,网上搜了一下教程,大多含糊不清,所以写下这个,权当总结,方便日后查看,如果能恰好帮到一些需要的人,那就更好了 先说需求,域名指向搭建了Nginx的 ...
- jquery中的ajax方法(备忘)
参考:https://www.cnblogs.com/tylerdonet/p/3520862.html w3school:http://www.w3school.com.cn/jquery/ajax ...