Maintenance scripts often remove generated files, but the planned command should be visible before it runs.

Program

Play the script to choose a retention window and see the cleanup command it would run.

keep_days
cleanup_plan.sh
Replay: real traced execution (multi-file project)
#!/usr/bin/env bash

keep_days=7
cache_dir="build-cache"
command="find $cache_dir -mtime +$keep_days -delete"
echo "$command"
#!/usr/bin/env bash

keep_days=14
cache_dir="build-cache"
command="find $cache_dir -mtime +$keep_days -delete"
echo "$command"
  1. keep_days ← 7

    3keep_days=74cache_dir="build-cache"
    values this step7keep_days
  2. cache_dir ← build-cache

    3keep_days=74cache_dir="build-cache"5command="find $cache_dir -mtime +$keep_days -delete"
    values this stepbuild-cachecache_dir
  3. command ← find build-cache -mtime +7 -delete

    4cache_dir="build-cache"5command="find $cache_dir -mtime +$keep_days -delete"6echo "$command"
    values this stepfind build-cache -mtime +7 -deletecommandbuild-cachecache_dir7keep_days
  4. echo "$command"

    5command="find $cache_dir -mtime +$keep_days -delete"6echo "$command"
    outputfind build-cache -mtime +7 -delete
    values this stepfind build-cache -mtime +7 -deletecommand
  1. keep_days ← 14

    3keep_days=144cache_dir="build-cache"
    values this step14keep_days
  2. cache_dir ← build-cache

    3keep_days=144cache_dir="build-cache"5command="find $cache_dir -mtime +$keep_days -delete"
    values this stepbuild-cachecache_dir
  3. command ← find build-cache -mtime +14 -delete

    4cache_dir="build-cache"5command="find $cache_dir -mtime +$keep_days -delete"6echo "$command"
    values this stepfind build-cache -mtime +14 -deletecommandbuild-cachecache_dir14keep_days
  4. echo "$command"

    5command="find $cache_dir -mtime +$keep_days -delete"6echo "$command"
    outputfind build-cache -mtime +14 -delete
    values this stepfind build-cache -mtime +14 -deletecommand
retention A retention window says how long generated files should be kept.
cleanup plan Printing the command first makes destructive maintenance easier to review.
side-effect boundary This lesson builds command text without deleting anything.