Linux systemd Services

Run apps as services: enable, restart, and read journals.

  • systemd
  • systemctl
  • journalctl
  • linux service
  • enable service

Linux systemd Services

Run apps as services: enable, restart, and read journals.

Commands

CommandWhat it does
systemctl status appHealth plus recent logs
systemctl enable now appStart now and on boot
systemctl restart appRestart after config change
journalctl -u app -fFollow service logs
journalctl bounded windowLogs from the last hour

Example

sudo systemctl enable --now app
systemctl is-active app

FAQ

Service fails at boot but not manually?

Environment and paths differ - declare working directory, user, and env files explicitly in the unit.

Where do stdout logs go?

The journal by default; add file output options for copies too.

常见问题

Service fails at boot but not manually?
Environment and paths differ - declare working directory, user, and env files explicitly in the unit.
Where do stdout logs go?
The journal by default; add file output options for copies too.

Linux