OS
[CentOS 7] rc.local 사용하기
- 비아웹 오래 전 2022.02.16 16:21 인기
-
- 3,370
- 0
1. rc-local 데몬 확인
[root@viaweb ~]# systemctl status rc-local
● 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)
2. rc-local.service 파일 가장 하단에 아래 내용 추가
[root@viaweb ~]# vi /usr/lib/systemd/system/rc-local.service
--/usr/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
:
:
(생략)
:
[Install]
WantedBy=multi-user.target
3. /etc/rc.local 파일 안에 'chmod +x /etc/rc.d/rc.local' 권한을 변경 해야한다고 명시되어있습니다.
[root@viaweb ~]# vi /etc/rc.local
--/etc/rc.local --
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
4. 권한 변경
[root@viaweb ~]# ls -l /etc/rc.d/rc.local
-rw-r--r--. 1 root root 473 Oct 2 2020 /etc/rc.d/rc.local
-- 권한변경 --
[root@viaweb ~]# chmod +x /etc/rc.d/rc.local
또는
[root@viaweb ~]# chmod 755 /etc/rc.d/rc.local
[root@viaweb ~]# ls -l /etc/rc.d/rc.local
-rwxr-xr-x. 1 root root 473 Oct 2 2020 /etc/rc.d/rc.local
5. rc-local 데몬 실행 및 자동실행 활성화
-- rc-local 데몬 시작 --
[root@viaweb ~]# systemctl start rc-local
[root@viaweb ~]# systemctl enable rc-local
[root@viaweb ~]# systemctl status rc-local
● rc-local.service -/etc/rc.d/rc.local Compatibility
Loaded:loaded(/usr/lib/systemd/system/rc-local.service;static; vendor preset: disabled)
Active:active(exited) since Wed 2021-06-02 09:57:55 KST; 13s ago
Jun 02 09:57:55 viaweb systemd[1]: Starting /etc/rc.d/rc.local Compatibility...
Jun 02 09:57:55 viaweb systemd[1]: Started /etc/rc.d/rc.local Compatibility.
Hint: Some lines were ellipsized, use -l to show in full.
감사합니다.
서버호스팅 비아웹
- 이전글[CentOS]route 추가 하기2022.02.16
- 다음글CentOS 7 systemd 데몬 관련 로그 필터링 설정2022.02.16
댓글목록
등록된 댓글이 없습니다.