背景
systemd is now used for user sessions. System sessions had already been provided by systemd in previous Ubuntu releases.
Ubuntu-18.04用 systemctl 命令来替换了 service 和 chkconfig 的功能。
比如以前启动mysql服务,命令为:
service mysql start
在Ubuntu-18.04启动mysql服务的命令则是:
systemctl start mysqld.service
systemd 默认读取 /etc/systemd/system 下的配置文件,该目录下的文件会链接/lib/systemd/system/下的文件。执行 ls /lib/systemd/system 你可以看到有很多启动脚本,其中就有我们需要的 rc.local.service。
打开rc.local.service脚本中的内容如下所示:
[Unit]
Description=/etc/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.local start
ExecStop=/etc/rc.local stop
ExecReload=/etc/rc.local restart
TimeoutSec=0
RemainAfter