Back to lessons

Hosting Operations

Exclude the Current Release from Cleanup

Several release directories exist and you need to identify stale candidates without touching the active symlink target.

Command

current=$(readlink -f /lab/disk-inode-cleanup/home/deploy/current); find /lab/disk-inode-cleanup/home/deploy/releases -mindepth 1 -maxdepth 1 -type d ! -samefile "$current" -printf '%TY-%Tm-%Td %p\n' | sort

What changed

Nothing changes. The command resolves the active release and prints only non-current candidates.

Danger

safe

When to use it

Use before release-directory cleanup on hosts that keep multiple deploy versions.

When not to use it

Do not delete old releases until rollback policy, backup state, and active symlinks are confirmed.

Undo or recovery

No undo needed because the command only resolves and prints paths.

Expected output

Older release directories, excluding the current symlink target.

demo script

Disposable terminal steps

  1. readlink -f /lab/disk-inode-cleanup/home/deploy/current
  2. current=$(readlink -f /lab/disk-inode-cleanup/home/deploy/current); find /lab/disk-inode-cleanup/home/deploy/releases -mindepth 1 -maxdepth 1 -type d ! -samefile "$current" -printf '%TY-%Tm-%Td %p\n' | sort

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ readlink -f /lab/disk-inode-cleanup/home/deploy/current
/lab/disk-inode-cleanup/home/deploy/releases/2026-06-25
::exit-code::0
$ current=$(readlink -f /lab/disk-inode-cleanup/home/deploy/current); find /lab/disk-inode-cleanup/home/deploy/releases -mindepth 1 -maxdepth 1 -type d ! -samefile "$current" -printf '%TY-%Tm-%Td %p\n' | sort
2026-06-01 /lab/disk-inode-cleanup/home/deploy/releases/2026-06-01
2026-06-18 /lab/disk-inode-cleanup/home/deploy/releases/2026-06-18
::exit-code::0

YouTube Short

Protect current release.

Before cleaning old releases, resolve the current symlink and exclude that target from the candidate list.

LinkedIn hook

Release cleanup should prove what current points to before listing old directories.

Question: What is your guardrail before deleting old release directories?

experiments

A/B tests to run

Metric: save_rate

A: Resolve current before cleanup.

B: Do not delete the active release.