명령

$ systemctl list-units
$ systemctl list-units --state=[failed, running, exited, plugged]
$ systemctl list-units | grep "yona"

$ service --status-all
$ systemctl status [*]
$ systemctl start [name]
$ systemctl stop [name]
$ systemctl status [name]
$ systemctl disable [name]
$ systemctl enable [name]
$ systemctl reset-failed # 불필요한 서비스를 삭제

$ systemctl daemon-reload
$ journalctl | grep [name] # 로그 확인

관련 파일 경로

/etc/systemd/system/*.service
/etc/systemd/system/multi-user.target.wants/*.service
/lib/systemd/system/*.service

service 파일 예

[Unit]
Description=yona_api - yona api service
Documentation=http://localhost:3000/yona/help
After=network.target

[Service]
SyslogIdentifier=yona_api
Type=simple
User=oiehot
#EnvironmentFile=/yona/api/env
Environment=YONA_API_PORT=3000
#WorkingDirectory=/
ExecStart=/usr/bin/node /yona/api/server.js >> /dev/null
Restart=on-failure
#Restart=always

[Install]
WantedBy=multi-user.target

참고자료