본문 바로가기

리눅스

[리눅스] 서비스(데몬) 등록 방법

728x90

리눅스 서비스(데몬) 등록 방법

chkconfig --add [서비스 명]

chkconfig --level [서비스 명]

chkconfig --del [서비스 명]

chkconfig --list [서비스 명]

CentOS 6 chkconfig 명령으로 서비스 관리

zabbix-agent 서비스 등록

chkconfig --add zabbix-agent

zabbix-agent 서비스 확인

$ chkconfig --list | egrep zabbix
zabbix-agent   	0:off	1:off	2:off	3:off	4:off	5:off	6:off

level 3, 5 일 경우 zabbix-agent 서비스 부팅

chkconfig --level 35 zabbix-agent on

zabbix-agent 서비스 확인

$ chkconfig --list | egrep zabbix-agent
zabbix-agent   	0:off	1:off	2:off	3:on	4:off	5:on	6:off

chkconfig --list

$ chkconfig --list

알림: 이 출력 결과에서는 SysV 서비스만을 보여주며 기존의 systemd 서비스는
포함되어 있지 않습니다. SysV 설정 데이터는 기존의 systemd  설정에 의해
덮어쓰여질 수 있습니다.

      'systemctl list-unit-files'를 사용하여 systemd 서비스를 나열하실 수 있습니다.
       특정 대상에 활성화된 서비스를 확인하려면
       'systemctl list-dependencies [target]'을 사용하십시오.

netconsole     	0:해제	1:해제	2:해제	3:해제	4:해제	5:해제	6:해제
network        	0:해제	1:해제	2:활성	3:활성	4:활성	5:활성	6:해제

CentOS 7 systemd(systemctl) 명령으로 서비스 관리

unit file 목록 확인

unit file 전체 목록 확인

systemctl list-unit-files

unit file 서비스 목록 확인

systemctl -t service list-unit-files

$ systemctl -t service list-unit-files
UNIT FILE                                     STATE
abrtd.service                                 enabled
anaconda.service                              static
atd.service                                   enabled
auditd.service                                disabled
ntpd.service                                  enabled
sshd.service                                  enabled
sshd@.service                                 static

서비스 등록(enabled)

systemctl enable zabbix-agent

서비스 해제(disable)

systemctl disable zabbix-agent

unit 목록 확인

systemctl list-units

systemctl list-units --all

UNIT - The name of the service unit.
LOAD - Information about whether the unit file has been loaded in the memory.
ACTIVE - The high-level unit file activation state, which can be active, reloading, inactive, failed, activating, deactivating. It is a generalization of the SUB column.
SUB - The low-level unit file activation state. The value of this field depends on the unit type. For example, a unit of type service can be in one of the following states, dead, exited, failed, inactive, or running.
DESCRIPTION - Short description of the unit file.

$ systemctl list-units
UNIT                  LOAD   ACTIVE SUB       DESCRIPTION
crond.service         loaded active running   Command Scheduler
ntpd.service          loaded active running   Network Time Service
zabbix-agent.service  loaded active running   Zabbix Agent
...

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

136 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

서비스 목록 확인

systemctl list-units --type service

$ systemctl list-units --type service
UNIT                               LOAD   ACTIVE SUB     DESCRIPTION
abrt-ccpp.service                  loaded active exited  Install ABRT coredump hook
abrt-oops.service                  loaded active running ABRT kernel log watcher
abrtd.service                      loaded active running ABRT Automated Bug Reporting Tool
atd.service                        loaded active running Job spooling tools
blk-availability.service           loaded active exited  Availability of block devices
containerd.service                 loaded active running containerd container runtime

systemctl list-units --type service --all

$ systemctl list-units --type service --all
  UNIT                        LOAD      ACTIVE   SUB     DESCRIPTION
  abrt-ccpp.service           loaded    active   exited  Install ABRT coredump hook
  abrt-oops.service           loaded    active   running ABRT kernel log watcher
  abrt-vmcore.service         loaded    inactive dead    Harvest vmcores for ABRT
  abrt-xorg.service           loaded    inactive dead    ABRT Xorg log watcher
  abrtd.service               loaded    active   running ABRT Automated Bug Reporting Tool
  atd.service                 loaded    active   running Job spooling tools
  ...
● yppasswdd.service           not-found inactive dead    yppasswdd.service
● ypserv.service              not-found inactive dead    ypserv.service
● ypxfrd.service              not-found inactive dead    ypxfrd.service
  zabbix-agent.service        loaded    active   running Zabbix Agent

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

163 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.

active 서비스(unit) 목록

systemctl list-units --state active

failed 서비스(unit) 목록

systemctl list-units --state failed
728x90