Debian \ Ubuntu 開機啟動
BUBU 因公司系統都是用 CentOS
服務,但是有些服務都是用 rc.local
這裡設定,那因現在要將該服務移轉到 Debian
來接續服務,因 Debain
並沒有該設定檔所以需手動新增該設定檔
- 先確認系統是否該有
rc.local
服務cat /lib/systemd/system/rc-local.service
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# 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
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
- 預設該服務目前是停用
- 因預設沒有
rc.local
需動新增
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
- 新增完後再給予該檔權限
chmod +x /etc/rc.local
- 啟動
rc-local
服務
systemctl start rc-local