Hosting Operations
Read-only, can be slowList Empty Directories as Cleanup Candidates
A cache tree may contain abandoned empty directories and you need to review them before cleanup.
Command
find /lab/disk-inode-cleanup/var/cache/app -xdev -depth -type d -empty -print
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 empty directories that applications expect to exist unless startup or deploy code recreates them.
Expected output
Paths to empty directories under the selected cache tree.
System impact
Read-only, can be slow. Nothing changes. The command prints empty directories without removing them.
May require elevated permissions on protected paths or service-owned files.
Scope this to the smallest useful path or service on busy systems.
Recovery / rollback: no state is changed.
When to use it
Use before pruning empty cache or working directories after a migration, deploy, or failed job.
When not to use it
Do not delete empty directories that applications expect to exist unless startup or deploy code recreates them.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ find /work/disk-inode-cleanup/var/cache/app -xdev -maxdepth 3 -type d -print | sort
/work/disk-inode-cleanup/var/cache/app
/work/disk-inode-cleanup/var/cache/app/empty-old
/work/disk-inode-cleanup/var/cache/app/shards
/work/disk-inode-cleanup/var/cache/app/shards/a
/work/disk-inode-cleanup/var/cache/app/shards/b
$ find /work/disk-inode-cleanup/var/cache/app -xdev -depth -type d -empty -print
/work/disk-inode-cleanup/var/cache/app/empty-old
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
find /lab/disk-inode-cleanup/var/cache/app -xdev -maxdepth 3 -type d -print | sortfind /lab/disk-inode-cleanup/var/cache/app -xdev -depth -type d -empty -print
next steps
Related commands
Find Directories Burning Inodes
Inode cleanup starts by finding the directory with too many files.
find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head
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
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
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
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
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.
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.