Skip to content

Lesson 3 of 3

Keeping your server healthy

1 min

A server that worked on day one drifts over time: disks fill, packages age, logs grow. A short routine prevents most surprises.

Weekly checks

df -h            # disk space
free -h          # memory
uptime           # load average
systemctl --failed

Keep disk usage under 80%. A full disk stops databases and mail without warning.

Updates

Install security updates automatically:

sudo apt install unattended-upgrades
sudo dpkg-reconfigure unattended-upgrades

Reboot during a quiet hour when /var/run/reboot-required exists (kernel updates need it).

Logs

Check /var/log/nginx/error.log and journalctl -p err -b after every change. Make sure logrotate is compressing old logs so they don't fill the disk.

Backups

Automate a nightly database dump and copy it off the server:

mysqldump --single-transaction shop | gzip > /backup/shop-$(date +%F).sql.gz

Monitoring beats checking. A free uptime monitor and a disk-space alert at 80% catch problems while you're asleep.