Quick reference
1. Don't
systemctl restart appRestarting first wipes out the evidence.
Do instead
journalctl -u app --since '10 min ago'Read what happened first. Then restart.
2. Don't
tail -f /var/log/app.logAfter log rotation, -f keeps watching the old file.
Do instead
tail -F /var/log/app.log-F follows the file name, even after rotation.
3. Don't
grep '03:00' app.logApp logs often use UTC. You may read the wrong hour.
Do instead
timedatectlCheck the server time zone before you compare times.
4. Don't
vi nginx.conf php.ini my.cnfThree changes at once. Which one fixed it, or broke it?
Do instead
git -C /etc commit -am 'one change'One change at a time, with a record of each.
5. Don't
journalctl -u appThe app log only shows the app. The cause may be below it.
Do instead
dmesg -T | tail -20Disk errors, OOM kills and hardware faults live here.
Explained
- Restarting first
systemctl restart appoften makes the symptom go away, and takes the explanation with it. Instead:journalctl -u app --since '10 min ago'first. Thirty seconds of reading tells you whether this will happen again tonight.
tail -fon a log that rotates When logrotate renames the file,tail -fkeeps watching the old one. The screen goes quiet and you think the problem stopped. Instead:tail -Ffollows the file name, and picks up the new file after rotation.
- Ignoring time zones The app logs in UTC, the server shows local time, and the monitoring tool uses a third. You end up comparing events that are hours apart. Instead: check
timedatectlfirst, and note which time zone each log uses before you build a timeline.
- Changing several things at once Three config files edited, one restart, and the problem is gone. Which change fixed it? Or which one will break something next week? Instead: one change, one test, and a record of it. With
/etcin git, every change is one commit.
- Only reading the app's log The application log only knows about the application. A failing disk, an OOM kill or a network driver problem happens below it. Instead:
dmesg -T | tail -20shows the kernel's side of the story, with readable timestamps.
The first two commands for any failing service: systemctl status app, then journalctl -xeu app.
In one line
Slow is smooth. Smooth is fast. Read first, change one thing, write it down.
The first two commands
systemctl status app; journalctl -xeu appMore notes: IT operations & incidents
Open in the notes app: search, filters, copy This note on GitHub