인프라/Linux

[Linux]Ubuntu에서 systemd 서비스 등록하기

김 숨 2024. 7. 25. 10:33

1. service 파일 생성

cd /etc/sytemd/sytemd
vi {서비스 명}.service

2. service 파일 내용 기입

[Unit]
Description=["디스크 명령어 입력시 알럿 보냄"]
After=multi-user.target

[Service]
Type=idle
ExecStart=/usr/bin/python3 /home/admin/es_alert/disk_alert_update.py


[Install]
WantedBy=multi-user.target

 

 

3. systemctl로 서비스 활성화

systemctl start {서비스 명}.service
systemctl enable {서비스 명}.service