Menjalankan dinamis command menggunakan systemd

Buat file service

nano /etc/systemd/system/[email protected]
[Unit]
Description=Zrok Share Reserved %i
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/local/bin/zrok share reserved %i --headless
WorkingDirectory=/root
User=root

Restart=always
RestartSec=5

StandardInput=null
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

Reload systemd

systemctl daemon-reload

Command lainnya

systemctl enable zrok@[cmd]             # enable startup
systemctl start zrok@[cmd]              # run service
systemctl status zrok@[cmd]             # show status
systemctl list-units "zrok@*"           # list all active zrok services
systemctl list-unit-files "zrok@*"      # list all enabled (even if not running)
journalctl -u "zrok@*" -f               # show logs all service
journalctl -u "zrok@[cmd]" -f           # show logs spesific service

Remove config

systemctl stop zrok@[cmd]
systemctl disable zrok@[cmd]
systemctl reset-failed zrok@[cmd]
rm /etc/systemd/system/[email protected]
systemctl daemon-reload

Last updated