Hosting Operations
Read-only, can be slowRank Old Cleanup Candidates by Size
You have old files in a cleanup path and need to review the largest candidates first without deleting anything.
Command
find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | head
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 the largest old file just because it is large; confirm ownership, retention, and whether a process still needs it.
Expected output
A largest-first list of old files with byte counts, dates, and paths.
System impact
Read-only, can be slow. Nothing changes. The command prints old files with byte sizes and sorts the candidates largest first.
May require elevated permissions on protected paths or service-owned files.
Scope this to the smallest useful path or service on busy systems.
When to use it
Use when cleanup pressure is urgent and you need to focus review on candidates that would actually reclaim space.
When not to use it
Do not delete the largest old file just because it is large; confirm ownership, retention, and whether a process still needs it.
Recovery / rollback
No undo needed because this command only prints candidate files.
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.
$ find /work/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | head
78643200 2026-06-01 /work/disk-inode-cleanup/var/tmp/uploads/old-export.tar
$ find /work/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%10s %TY-%Tm-%Td %p\n' | sort -nr | awk '{printf "%.1f MB %s %s\n", $1/1024/1024, $2, $3}'
75.0 MB 2026-06-01 /work/disk-inode-cleanup/var/tmp/uploads/old-export.tar
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | headfind /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%10s %TY-%Tm-%Td %p\n' | sort -nr | awk '{printf "%.1f MB %s %s\n", $1/1024/1024, $2, $3}'
next steps
Related commands
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
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
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
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
Exclude the Current Release from Cleanup
Release cleanup should prove what current points to before listing old directories.
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
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.