Stop your CI runner from eating all the disk space with orphaned temp files

DevOps Tooling On Linux (CI/CD Runners, Ansible)

Stop your CI runner from eating all the disk space with orphaned temp files

Technical Briefing | 11/23/2026

You probably have a runner node that looks fine in the dashboard, but you keep getting build failures about no space left on device. It’s almost never the source code itself. CI systems love to create temporary build artifacts and workspace directories, and if a build gets killed midway, those directories stick around like a bad habit. I have spent too many mornings clearing out /tmp or runner-specific work directories because the cleanup script didn’t account for a SIGKILL.

Why relying on the runner daemon to clean up is a gamble

Most runners are configured to purge workdirs after a job finishes. But what happens when the underlying process hits a memory limit or the kernel OOM killer steps in? The cleanup routine never fires. The job is marked as failed, but the disk space remains allocated. If you run a high-concurrency setup, these zombies accumulate, and eventually, the node hits capacity. You need a sidecar process or a system-level cleanup task that doesn’t trust the application layer to handle its own garbage.

find /var/lib/gitlab-runner/builds -mindepth 1 -maxdepth 2 -type d -mtime +1 -exec rm -rf {} +

  • Use find with mtime to safely ignore builds active in the last 24 hours
  • Restrict maxdepth so you don’t accidentally nuke your system root
  • Trigger this via a systemd timer rather than adding it to the end of your pipeline scripts

This isn’t just about disk space; it’s about avoiding weird file permission issues when a new job tries to recycle a directory owned by a failed build’s UID. If you keep seeing artifacts from three weeks ago, you are just waiting for a build to fail because of a file collision. Check your runner directory structure today and see how many gigabytes of dead builds you’re actually paying to host.

Linux Admin Automation  |  © www.ngelinux.com  |  11/23/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted