티스토리 뷰

Linux

systemctl (systemd) 명령어

CHOMAN 2015. 6. 4. 16:11


systemctl (systemd)



CENTOS6 부터 적용 (sysv init -> systemd) 

초기 실행되는 서비스들의 의존성을 제거하고 병렬로 실행할수 있으므로 부팅 속도가 빠름

on-demand 방식 실행 지원 : 요청이 오면 프로세스를 실행함


직렬처리


init : 1->2->3->4->


병렬처리


systemd

1-> 5

2-> 5

3-> 5

4-> 5




서비스 정보보기 : systemctl list-unit-files


서비스 시작 : systemctl start [서비스명]

서비스 중지 : systemctl stop [서비스명]


서비스 활성화 : systemctl enable [서비스명]

서비스 비활성화 : systemctl disable [서비스명] 





systemctl 

전체 서비스 목록 조회




Centos7 설치후 잡다한 프로세스들이 많이 떠 있어서 나한테 불필요한 데몬들을 제거하였다.



systemctl disable atd.service

systemctl disable auditd.service

systemctl disable avahi-daemon.service

systemctl disable dbus-org.fedoraproject.FirewallD1.service

systemctl disable dbus-org.freedesktop.Avahi.service

systemctl disable firewalld.service

systemctl disable kdump.service

systemctl disable microcode.service

systemctl disable postfix.service

systemctl disable systemd-readahead-collect.service

systemctl disable systemd-readahead-drop.service

systemctl disable systemd-readahead-replay.service

systemctl disable tuned.service

systemctl disable avahi-daemon.socket

systemctl disable default.target

systemctl disable multi-user.target

systemctl disable remote-fs.target






제거하고 난뒤 enable 한 서비스는 아래와 같음



[root@localhost ~]# systemctl list-unit-files

crond.service                                                                     enabled 

dbus-org.freedesktop.NetworkManager.service      enabled 

dbus-org.freedesktop.nm-dispatcher.service            enabled 

getty@.service                                                                  enabled 

irqbalance.service                                                            enabled 

NetworkManager-dispatcher.service                          enabled 

NetworkManager.service                                              enabled 

rsyslog.service                                                                   enabled 

sshd.service                                                                        enabled



enable (자동시작 설정), disable (자동시작 안함), static (단독으로 실행할수 없음)





enabled / disabled된 서비스 검색



systemctl is-enabled [서비스 이름]

systemcl is-disabled [서비스 이름]

 




스크립트 경로



/lib/systemd

/lib/systemd/system

 




부팅에 걸린시간 (systemd-analyze)



[root@localhost system]# systemd-analyze

Startup finished in 1.678s (kernel) + 5.065s (initrd) + 1min 4.436s (userspace) = 1min 11.180s




부팅시 실패한 서비스 목록



[root@localhost system]# systemctl --failed

  UNIT                         LOAD   ACTIVE SUB    DESCRIPTION

● systemd-modules-load.service loaded failed failed Load Kernel Modules


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.


1 loaded units listed. Pass --all to see loaded but inactive units, too.

To show all installed unit files use 'systemctl list-unit-files'.

 



현재 정상적으로 실행되고 있는 서비스 목록 검색



[root@localhost system]# systemctl is-active libvirtd

active


[root@localhost system]# systemctl is-active xendomains

inactive




systemctl kill [서비스이름]


: "서비스이름" 과 연관된 프로세스 종료시킴






원문 및 참고사이트



https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/chap-managing_services_with_systemd


https://blog.naver.com/esh9760/221394917203


https://blog.naver.com/andwise/221029670946

 




[출처] : https://access.redhat.com


DirectoryDescription
/usr/lib/systemd/system/Systemd unit files distributed with installed RPM packages.
/run/systemd/system/Systemd unit files created at run time. This directory takes precedence over the directory with installed service unit files.
/etc/systemd/system/Systemd unit files created by systemctl enable as well as unit files added for extending a service. This directory takes precedence over the directory with runtime unit files.


'Linux' 카테고리의 다른 글

리눅스 명령어 정리  (0) 2015.06.04
/etc/shadow 파일 구조  (0) 2015.06.04
리눅스에서 run 파일 실행시키기  (0) 2015.06.04
Can't exec "aclocal" 관련 에러  (0) 2015.06.04
리눅스 시간 동기화 명령어 (rdate)  (0) 2015.06.04
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함