Back to commands

Hosting Operations

Read-only, can be slow

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

Before you run this

System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.

When not to use it: Do not delete old releases until rollback policy, backup state, and active symlinks are confirmed.

Expected output

Older release directories, excluding the current symlink target.

System impact

Read-only, can be slow. Nothing changes. The command resolves the active release and prints only non-current candidates.

Scope this to the smallest useful path or service on busy systems.

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.

Recovery / rollback

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

Explanation-only example

Illustrated output, not a live lab run

This example is intentionally illustrative. It shows the command shape without killing real processes or changing your machine.

demo@lab:~$

$ readlink -f /work/disk-inode-cleanup/users/deploy/current

/work/disk-inode-cleanup/users/deploy/releases/2026-06-25

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

2026-06-01 /work/disk-inode-cleanup/users/deploy/releases/2026-06-01
2026-06-18 /work/disk-inode-cleanup/users/deploy/releases/2026-06-18
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  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

next steps

Related commands

Hosting Operations Can be slow

Show Release Directory Ages

See your newest release directories without opening a dashboard.

find releases/ -mindepth 1 -maxdepth 1 -type d -printf '%T@ %TY-%Tm-%Td %TH:%TM %p\n' | sort -nr | head -10 | cut -d' ' -f2-
Hosting Operations Can be slow

Preview Old Temp Files Before Deleting

The safe version of cleanup is a candidate list first.

find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %10s %p\n' | sort
Hosting Operations Can be slow

Rank Old Cleanup Candidates by Size

The oldest file is not always the file that buys back meaningful space.

find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | head
Hosting Operations Can be slow

Review Log Files Before Cleanup

Before truncating logs, prove which log files are large and how old they are.

find /lab/disk-inode-cleanup/var/log -xdev -type f -printf '%10s %TY-%Tm-%Td %p\n' | sort -nr
Hosting Operations Can be slow

Summarize Cache File Ages

Cache cleanup is safer when you know whether files are stale or still active.

find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • lpic1:103-gnu-unix-commands
  • lpic1:104-filesystems-permissions-fhs
  • lfcs:essential-commands
  • lfcs:operations-deployment
  • lfcs:services-logs
  • lfcs:storage
  • linuxplus:automation-scripting
  • linuxplus:provisional
  • linuxplus:system-management
  • risk:read-only

Useful for

  • LPIC-1 style command-line practice
  • LFCS style performance tasks
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.