Running a small Linux box
Most of what I run lives on one small machine. Not because it is the right architecture for everything, but because a single box is something I can hold in my head completely — every service, every port, every log file. That mental model is worth more to me than horizontal scale I do not need.
These are the habits that have kept it from turning into a source of surprises.
Let the system do the scheduling
I used to have a pile of while true; sleep 60 loops in screen sessions. They
worked until they silently did not, usually after a reboot. Everything like that
is now a systemd timer or a cron entry, so the system knows about it and so do
systemctl list-timers and journalctl.
# a timer that runs a script every ten minutes
systemctl list-timers --all
journalctl -u myjob.service --since '1 hour ago'
The second command is the one I actually use. If a scheduled job fails, the question is never “did it run” but “what did it print when it ran”, and having that answer in one place is the whole value of using the system scheduler.
Logs should rotate before you notice
An unrotated log file is a slow-motion outage. The disk fills, and the first symptom is not “disk full” — it is some unrelated service failing to write something. I set rotation at creation time now, not after the first incident.
Make the box explain itself
Two things I check before anything else when something feels wrong:
systemctl --failed— anything in a restart loop.df -h /— the most common cause of strange behavior on a small disk.
Both take under a second and between them they account for most of the problems I have had. A box that can answer “what is broken right now” quickly is much easier to keep running than one where every question requires an investigation.
Updates, but on a schedule you chose
Unattended upgrades are tempting and I do use them for security patches. But there is a real difference between “apply security fixes automatically” and “restart my services whenever upstream feels like it”. I keep the automatic part narrow, and I do the restarts myself during a window where I can watch them.
Backups are not real until restored
I had a backup job run successfully every night for eleven months before I tried to restore from it. It did not work — the archive was being written before the database flushed. Nothing in the logs said anything was wrong.
Now the restore is part of the backup. Once a quarter I pull an archive to a scratch machine, restore it, and confirm the result is usable. It takes twenty minutes and it is the only way to know the job means anything.
Boring is the goal
None of this is clever. It is a collection of defaults chosen so that the failure modes are the ones I already know how to handle. For a box that mostly needs to keep being there, that is the right kind of engineering.