[root@debian /root]# cat /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 # (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 Documentation=man:systemd-rc-local-generator(8) ConditionFileIsExecutable=/etc/rc.local After=network.target
[root@debian /root]# 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
赋予配置文件权限
1
[root@debian /root]# chmod +x /etc/rc.local
启动 rc-local 服务
1
[root@debian /root]# systemctl start rc-local
查看服务状态
1 2 3 4 5 6 7 8 9 10 11
[root@debian /root]# 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: /usr/lib/systemd/system/rc-local.service.d └─debian.conf Active: active (exited) since Tue 2020-03-17 10:04:27 CST; 9s ago Docs: man:systemd-rc-local-generator(8) Process: 18500 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)