Disk on a Linux app server keeps filling up overnight. How do you find and fix it?
BeginnerScenarioScaling and performance
Answer
Situation read → Something writes faster than it's cleaned up: logs, temp files, core dumps, or deleted files still held open.
What I'd do →
- Find what's big:
df -h
sudo du -xh / --max-depth=2 2>/dev/null | sort -rh | head -20
- If
dfshows full butdudoesn't add up, a deleted file is still open:
sudo lsof +L1
Restart the process holding it, or truncate via /proc/<pid>/fd/<n>.
3. Check usual suspects: /var/log, the journal (journalctl --disk-usage), Docker images and volumes (docker system df).
4. Fix: logrotate with compress and maxsize, SystemMaxUse= in journald, docker system prune on a schedule, and ship logs off the box.
5. Alert at 80% disk with a predictive rule (predict_linear on node_filesystem_avail_bytes).
Why → lsof +L1 catches the case where deleting the log didn't free space.
Interview tip → The deleted-but-open file is a favourite follow-up; mention it before they ask.
More on Scaling and performance
Traffic is expected to 10x for a sale next week. How do you prepare the platform?IntermediateThe HPA is configured but pods don't scale even though the app is slow. Why?BeginnerPods are Pending during a traffic spike because the cluster is out of capacity. What do you do now and long term?IntermediateThe database CPU is at 95% and the API is timing out. What's your approach?Intermediate"Too many connections" errors from Postgres after scaling the app out. How do you fix it?IntermediateLatency is fine on average but p99 is terrible. Where do you look?Advanced