>_ IzzyLab

Hands-on task

This task is step 15 of the course “Running a server”

systemd: write and validate a unit

medium~7 min

Write the service unit file /etc/systemd/system/myapp.service: Type=simple, runs /usr/bin/sleep 60, hooks into the multi-user.target target. It must pass systemd-analyze verify without errors.

What you'll practise:
  • systemd
  • unit files
  • ExecStart
  • systemd-analyze
  • multi-user.target

Topic breakdown

A systemd unit is a declarative INI file where each section covers its own aspect of a service's life: [Unit] describes metadata and dependencies, [Service] — what to run and how the manager should treat the process (the Type directive defines the startup model), [Install] — where the unit "hooks in" when activated via enable. Type=simple tells systemd that the process from ExecStart is itself the service's main process, not a forking daemon. A separate point is validation: systemd-analyze verify parses the file and points out typos and non-existent directives without actually starting the service.

What's checked

  1. unit created, ExecStart in the [Service] section
  2. Type=simple in [Service], WantedBy=multi-user.target in [Install]
  3. unit passes systemd-analyze verify with no remarks

What it looks like