Welcome to Firefly
Switch language
Firefly Docsss
Last Updated: 2026-08-27 07:36:09

Ubuntu/Debian systemd Service Autostart

For applications that should run as a background service, create a systemd unit.

Create /etc/systemd/system/myapp.service:

[Unit]
Description=My Application
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=firefly
WorkingDirectory=/home/firefly/myapp
ExecStart=/home/firefly/myapp/myapp
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable --now myapp.service
sudo systemctl status myapp.service

View logs:

journalctl -u myapp.service -f

If the service starts a GUI program, set the required display environment and permissions, for example:

Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/firefly/.Xauthority

On this page