728x90
Amazon Linux에서 rc-local(rc.local) 기능 활성화
rc-local(/etc/rc.local)을 통한 자동실행
$ systemctl status rc-local.service
● rc-local.service - /etc/rc.d/rc.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static; vendor preset: disabled)
Active: inactive (dead)
rc-local.service 파일 확인
- 이 스크립트가 부팅 중에 실행되도록 하려면 'chmod +x /etc/rc.d/rc.local'을 실행해야 합니다.
$ vim /lib/systemd/system/rc-local.service
# 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.d/rc.local is executable.
[Unit]
Description=/etc/rc.d/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
RemainAfterExit=yes
rc-local(/etc/rc.local) 서비스를 실행
rc-local.service 파일 편집
- [Install]
- WantedBy=multi-user.target
$ vim /lib/systemd/system/rc-local.service
# 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.d/rc.local is executable.
[Unit]
Description=/etc/rc.d/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
rc.local(/etc/rc.d/rc.local) 파이션 변경
$ chmod +x /etc/rc.d/rc.local
rc-local(/etc/rc.local) 서비스를 실행
$ systemctl --now enable rc-local.service
rc-local.service 상태 확인
$ sudo systemctl status rc-local.service
● rc-local.service - /etc/rc.d/rc.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled; vendor preset: disabled)
Active: active (exited) since Sat 2021-10-30 23:07:17 KST; 1min 15s ago
Process: 4250 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)
Oct 30 23:07:17 vamocha-01 systemd[1]: Starting /etc/rc.d/rc.local Compatibility...
Oct 30 23:07:17 vamocha-01 systemd[1]: Started /etc/rc.d/rc.local Compatibility.
728x90
'퍼블릭 클라우드' 카테고리의 다른 글
Amazon Linux 2에서 goofys 설치 및 S3 마운트하기 (0) | 2021.11.08 |
---|---|
AWS S3 버킷의 액세스를 IP 주소로 제한하는 방법 (0) | 2021.11.03 |
[aws] EC2 접속 시 슬랙으로 알림 보내기 (0) | 2021.10.30 |
Amazon EC2 인스턴스에 정적 호스트 이름을 할당하기 (0) | 2021.10.30 |
AWS 리소스의 네이밍 규칙(태그 이름) (0) | 2021.10.30 |