>_ IzzyLab

Hands-on task

This task is step 5 of the course “Running a server”

Disk is full

medium~5 min

The disk-space alert is firing. Free up space: in /var/data delete all files strictly larger than 10 MiB, and in /var/log/app — all compressed (.gz) logs. Don't touch anything else.

What you'll practise:
  • find
  • search by size
  • search by name
  • du
  • precise deletion

Topic breakdown

Bulk deletion of files by criteria is a job for find, which walks the directory tree and selects files by conditions: size (-size with the + prefix for "strictly greater than", with a units suffix) and name (-name with a pattern), after which an action like -delete is applied to the selected ones. Before scouting it's useful to assess what's taking up space with the du utility. The main principle is precision: the conditions are set so that exactly the right files get deleted and not a single extra one; a safe habit is to first run the same find without the delete action and check the list by eye.

What's checked

  1. files larger than 10 MiB in /var/data deleted
  2. compressed logs in /var/log/app deleted
  3. needed files preserved
  4. files no larger than 10 MiB are untouched

What it looks like