Ubuntu 16.10开始不再使用initd管理系统,改用systemd,包括用systemctl命令来替换了service和chkconfig的功能。比如以前启动mysql服务用
sudo service mysql start,现在用sudo systemctl start mysqld.service。systemd 默认读取 /etc/systemd/system 下的配置文件,该目录下的文件会链接/lib/systemd/system/下的文件。
执行命令ls /lib/systemd/system可以看到很多启动脚本,其中就有我们需要的rc.local.service,打开脚本内容如下
# SPDX-License-Identifier: LGPL-2.1+
#
# 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

Ubuntu 18.04从16.10开始采用systemd管理系统,开机自启动服务需通过systemctl命令操作。文章介绍了如何编辑启动脚本的[Unit]、[Service]和[Install]段,并创建软链接到/etc/systemd/system目录,以实现开机启动。同时,还讲解了如何创建和设置/etc/rc.local文件,赋予其可执行权限,并测试脚本确保启动成功。
最低0.47元/天 解锁文章
3876

被折叠的 条评论
为什么被折叠?



