← All guides

Programmer’s Reference

systemd

Read service state, inspect logs, and understand units and timers.

Linux hosts using systemd. demo-worker.service is an illustrative unit, not a WGS production service.

8 entries · Essentials first · Reviewed October 5, 2026

Glossary: commands, keywords & terms

Select a term for its definition, syntax, example, and common mistakes.

Essentials

Read and follow the journal

Show recent messages for a unit; follow new messages until Ctrl+C.

Terminal
journalctl -u demo-worker.service -n 50 --no-pager
journalctl -u demo-worker.service -f

Practical useInvestigate a staging backend failure.

Common mistakesYou may need sudo or journal group membership. Do not publish logs containing credentials or private data. Ctrl+C exits the viewer.

Source: www.freedesktop.org documentation (1) · github.com documentation (2)

Units and configuration

Inspect the effective unit

Read unit files/drop-ins and selected resolved properties.

Terminal
systemctl cat demo-worker.service
systemctl show demo-worker.service -p FragmentPath -p User -p ExecStart

Practical useCheck which demo executable is configured.

Common mistakesOutput can reveal private command arguments. Use fixed property selections and sanitize public examples.

Source: www.freedesktop.org documentation (1) · github.com documentation (2)

Write a simple service unit

Define a long-running demo Python worker under a pre-created unprivileged user.

systemd configuration
[Unit]
Description=Demo worker
After=network.target

[Service]
Type=simple
User=demo-worker
WorkingDirectory=/srv/demo-worker
ExecStart=/usr/bin/python3 /srv/demo-worker/worker.py
Restart=on-failure

[Install]
WantedBy=multi-user.target

Practical usePrototype a separate staging worker; reuse the real application’s established unit for actual operations.

Common mistakesThe user, script, and directory must already exist. network.target does not guarantee external network readiness. Avoid embedding secrets in ExecStart.

Source: www.freedesktop.org documentation (1) · www.freedesktop.org documentation (2) · github.com documentation (3) · github.com documentation (4)

Verify and reload unit definitions

Check a demo unit file and tell the manager to reread unit definitions.

⚠ Caution: Changes the service manager’s loaded definitions.

Terminal
systemd-analyze verify ./demo-worker.service
sudo systemctl daemon-reload

Practical useValidate a proposed staging unit before activating it.

Common mistakesdaemon-reload does not restart the application or reload its own configuration. Install the intended unit first; heed verification errors.

Source: www.freedesktop.org documentation (1) · www.freedesktop.org documentation (2) · github.com documentation (3) · github.com documentation (4)

Service changes

Start, stop, restart, and enable

Start a demo unit now and enable it for boot. Review stop/restart as separate actions.

⚠ Caution: Starts a process and changes boot behavior. stop/restart interrupt the service.

Terminal
sudo systemctl start demo-worker.service
sudo systemctl enable demo-worker.service
# Separate actions, run only when intended:
# sudo systemctl stop demo-worker.service
# sudo systemctl restart demo-worker.service

Practical usePractice service lifecycle controls on an isolated demo worker.

Common mistakesenable alone does not start a service. restart may start an inactive service; stop interrupts current work.

Source: www.freedesktop.org documentation (1) · github.com documentation (2)

Scheduling

Back to top ↑