Linux Survival Basics
Read Current-Boot Logs for One Service
Old service logs can make a current incident look worse or point you at errors from last week.
Command
journalctl -u nginx -b --no-pager -n 80
What changed
Nothing changes. journalctl prints the last 80 current-boot log entries for the unit.
Danger
safe
When to use it
Use after a reboot or restart when you only care about the current boot session.
When not to use it
Do not use for pre-reboot diagnosis; remove -b or use --since with an exact time range.
Undo or recovery
No undo needed because the command is read-only.
Expected output
Recent current-boot journal lines for nginx.
demo script
Disposable terminal steps
journalctl -u nginx -b --no-pager -n 80journalctl --disk-usage
simulated output
What it looks like
::fixture-ready::
$ journalctl -u nginx -b --no-pager -n 80
Jun 25 14:12:10 vps nginx[842]: start worker processes
Jun 25 14:12:11 vps nginx[842]: ready for connections
Jun 25 14:18:42 vps nginx[842]: reload complete
::exit-code::0
$ journalctl --disk-usage
Archived and active journals take up 412.8M in the file system.
::exit-code::0
YouTube Short
Read only this boot's service logs.
When a server has rebooted, stale logs can waste your time. Add -b to journalctl and cap the output.
LinkedIn hook
Ignore stale logs and inspect only what happened since this boot.
Question: How often have old logs sent you down the wrong debugging path?
experiments
A/B tests to run
Metric: save_rate
A: Avoid stale logs.
B: Post-reboot diagnosis needs -b.