ubuntu-18.04设置systemctl开机启动脚本rc.local
使用update-rc.d以及rc.local等方法就是不生效。后来在ubuntu的官方论坛ubuntu-16.10开始不再使用initd管理系统改用systemd ubuntu-18.04 LTS版本用的是systemctl命令来替换了service和chkconfig的功能。 systemd is now used for user sessions. System sessions had already been provided by systemd in previous Ubuntu releases. 比如以前启动 mysql 服务用: sudo service mysql start 现在用: sudo systemctl start mysqld.service 其实这个改动到不是算大,主要是开机启动比以前复杂多了。systemd 默认读取 /etc/systemd/system 下的配置文件,该目录下的文件会链接/lib/systemd/system/下的文件。 执行 ls /lib/systemd/system 你可以看到有很多启动脚本,其中就有我们需要的 rc.local.service 打开脚本内容: cat /lib/systemd/system/rc.local.service 可以看出/lib/systemd/system/rc.local.service的启动顺序是没有Install段 # 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 一般正常的启动文件主要分成三部分 ...