全球主机交流论坛

标题: 各位大佬,请问下debian9怎么设置开机启动 [打印本页]

作者: 3000    时间: 2018-11-10 18:41
标题: 各位大佬,请问下debian9怎么设置开机启动
各位大佬,请问下debian9怎么设置开机启动

centos那些的话是直接在/etc/rc.local里面加,但是Debian9里面没有这个文件,我试着自己加了文件,然后按照网上说的,要启动rc-loacl服务,结果报错

root@iZm5e8p616e5848vln6s3gZ:~# 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)
Condition: start condition failed at Sat 2018-11-10 18:01:27 CST; 34min ago
           └─ ConditionFileIsExecutable=/etc/rc.local was not met

作者: fl20002    时间: 2018-11-10 18:42
首先,需要在debian9中开启开机自启服务,创建/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 运行命令:  chmod +x /etc/rc.local赋予执行权限  systemctl start rc-local启动服务  这样,我们只需要将需要执行的命令写在/etc/rc.local的exit 0前面,就可以在开机后自动执行。
作者: ChinaDNS    时间: 2018-11-10 18:44
https://sb.sb/blog/debian-9-rc-local/
作者: binghe    时间: 2018-11-10 18:44
提示: 作者被禁止或删除 内容自动屏蔽
作者: 3000    时间: 2018-11-10 18:52
原来是最头部必须加那个脚本类型声明。

多谢楼上几位大哥指点
作者: hxuf    时间: 2018-11-10 19:00
debian9太麻烦 所以我还是比较喜欢debian7-8
作者: 3000    时间: 2018-11-10 19:03
hxuf 发表于 2018-11-10 19:00
debian9太麻烦 所以我还是比较喜欢debian7-8

麻烦在哪里?
作者: hxuf    时间: 2018-11-10 19:30
3000 发表于 2018-11-10 19:03
麻烦在哪里?

还需要开启那个rc.local 。




欢迎光临 全球主机交流论坛 (https://loc.mjj8.eu.org/) Powered by Discuz! X3.4