반응형
우분투 24.04에서 rc.local을 활성화하는 방법
우분투 24.04에서는 기본적으로 rc.local 스크립트 실행이 비활성화되어 있으며, rc-local 서비스도 기본으로 제공되지 않습니다. 수동으로 설정해서 rc.local을 사용할 수 있습니다.
테스트 환경
$ lsb_release -d
Description: Ubuntu 24.04.1 LTS
rc-local 서비스 활성화
1. rc-local 서비스 상태 확인
systemctl status rc-local.service
$ systemctl status rc-local.service
○ rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; static)
Drop-In: /usr/lib/systemd/system/rc-local.service.d
└─debian.conf
Active: inactive (dead)
Docs: man:systemd-rc-local-generator(8)
2. /etc/rc.local 스크립트 생성
printf '%s\n' '#!/bin/bash' 'exit 0' | sudo tee -a /etc/rc.local
(또는)
sudo vim /etc/rc.local
#!/bin/bash
# 명령어들을 여기에 추가
echo "rc.local executed on $(date)" >> /var/log/rc.local.log
exit 0
- 반드시 #!/bin/bash로 시작해야 하며 맨 마지막 줄에 exit 0이 포함되어야 합니다.
3. /etc/rc.local 스크립트 실행 권한 설정
sudo chmod +x /etc/rc.local
4. rc-local.service(/lib/systemd/system/rc-local.service) 파일 생성
아래 내용을 파알에 추가합니다.
cat << EOF >> /lib/systemd/system/rc-local.service
[Install]
WantedBy=multi-user.target
EOF
728x90
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
[Install]
WantedBy=multi-user.target
5. systemd 데몬 리로드
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
6. rc-local 서비스 활성화 및 시작
sudo systemctl enable --now rc-local.service
더보기
systemctl --now enable rc-local
$ systemctl --now enable rc-local
Created symlink /etc/systemd/system/multi-user.target.wants/rc-local.service → /lib/systemd/system/rc-local.service.
---
7. 상태 확인
systemctl status rc-local
$ systemctl status rc-local
● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Drop-In: /usr/lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (exited) since Fri 2022-10-21 13:09:33 KST; 3min 57s ago
Docs: man:systemd-rc-local-generator(8)
Process: 5330 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
CPU: 2ms
Oct 21 13:09:33 replydb-245 systemd[1]: Starting /etc/rc.local Compatibility...
Oct 21 13:09:33 replydb-245 systemd[1]: Started /etc/rc.local Compatibility.
이 명령은 /etc/rc.local 파일을 활성화하고 현재 상태를 확인합니다.
참고: 실행 로그는 /var/log/rc.local.log 또는 journalctl -u rc-local로 확인 가능합니다.
반응형
'리눅스' 카테고리의 다른 글
우분투 24.04에서 systemd-resolved를 비활성화하는 방법 (0) | 2025.05.28 |
---|---|
VMware ESXi에서 실행 중인 우분투 가상 머신에서 GRUB 부트 메뉴에 진입하는 방법 (0) | 2025.05.28 |
SSL 인증서 레벨의 특징과 주요 사용 사례 (0) | 2025.05.26 |
우분투 24.04에서 스크립트를 사용하여 최신 버전의 Docker를 설치하는 방법 (0) | 2025.05.26 |
우분투 24.04에 최신 버전의 Redis 서버를 설치하는 방법 (0) | 2025.05.26 |