본문 바로가기

퍼블릭 클라우드

[aws] Amazon Linux에서 rc-local(rc.local) 기능 활성화

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