Logs with journald
If a service failed, journalctl is often the shortest path to the reason.
Core commands
Section titled “Core commands”journalctl -u <service-name> # show logs for one servicejournalctl -u <service-name> -n 100 # show the last 100 log lines for one servicejournalctl -u <service-name> -f # follow new log lines livejournalctl -b # show logs from the current bootjournalctl -b -1 # show logs from the previous bootjournalctl -p err # show error-level logsjournalctl --since '1 hour ago' # show logs from a recent time windowMost useful patterns
Section titled “Most useful patterns”Current boot only:
journalctl -bPrevious boot:
journalctl -b -1Follow logs live for one service:
journalctl -u <service-name> -fLast 50 lines with no pager noise:
journalctl -u <service-name> -n 50 --no-pagerWhat to look for
Section titled “What to look for”- Restart loops
- Permission denied errors
- Missing file or bad path errors
- Port bind failures
- DNS or network timeout errors
- Config parse failures after a deploy
Common mistake
Section titled “Common mistake”If you restart a service several times, old failures can mix with new ones. Use --since or focus on the current boot to avoid reading stale noise.