systemd records what happens to services. This step shows how to read the records of a single service.
Messages from services and from systemd itself go to the system journal, which journalctl reads:
The -u option keeps the records of one unit, -n sets how many of the latest records to show, and --no-pager prints them straight to the terminal.
Service and system records are readable by root and the adm and systemd-journal groups, while student sees only its own. That is why a service journal is read through sudo: without it, journalctl -u cron prints the hint Hint: You are currently not seeing messages from other users and the system and -- No entries --, and systemctl status prints the state with no journal lines.
The records of both services
cron and nginx have just gone through the same crash as at the start of the lesson. Read the last eight journal records of each service.
systemd writes the crash records under its own name, systemd[1]:
| Record | What it means |
|---|---|
Main process exited, code=killed, status=9/KILL |
the main process was killed by the KILL signal |
Failed with result 'signal' |
the service went down; its state is failed |
Scheduled restart job, restart counter is at 1 |
Restart=on-failure fired; this is restart number one |
Started cron.service - … |
systemd started a new process for the service |
The record Referenced but unset environment variable … EXTRA_OPTS appears every time cron starts: its ExecStart contains the variable $EXTRA_OPTS, nobody has set it, and systemd put an empty string in its place.