Back to practice tasks

practice task

Read Recent Logs for One Service

A service restarted during deploy and is now unhealthy. You need the recent unit logs, not every log line on the machine.

Independent study support only. No affiliation, endorsement, exam dumps, or guaranteed exam results.

Try first

journalctl -u nginx --since '30 minutes ago' --no-pager

Goal

Show recent journal entries for one systemd unit with timestamps and enough context to spot the first failure.

Expected output

Recent log lines for the nginx unit only, usually including start, reload, error, or configuration-test messages.

Teaches

Narrow logs by unit and time window so the first useful error is visible quickly.

Common mistake

Using tail on a guessed log file while the service writes its useful failure details to journald.

command set

Commands to know

  1. systemctl status nginx --no-pager
  2. journalctl -u nginx --since '30 minutes ago' --no-pager
  3. journalctl -u nginx -b --no-pager

Watch this command run

Example output from a temporary Linux lab

next practice

Check Whether Nginx Config Is Valid

A teammate changed a server block and wants to reload nginx. You need to prove the configuration parses before touching the running service.