IT/Linux

리눅스 서비스 등록 및 systemctl로 관리

나떼~ 2024. 2. 18. 20:36
728x90

Service 등록

서비스를 등록하기 위해 아래 경로에 아래와 같이 설정을 한다.

# vi /etc/systemd/system/testchk.service

// /etc/systemd/system/testchk.service 내용
[Unit]
Description=Systemd Test Daemon

[Service]
Type=simple
ExecStart=/root/test-daemon.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target

 

재부팅 후에도 서비스 시작되도록 등록

# systemctl enable testchk

 

Service 시작

# systemctl start testchk

 

Service 재시작

# systemctl restart testchk

 

Service 종료

# systemctl stop testchk

 

Service 상태체크

# systemctl status testchk
728x90
반응형