Hosting Operations
Read-only, can be slowPreview Old Temp Files Before Deleting
A temporary upload directory may contain stale files, but you need evidence before removing anything.
Command
find /var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %10s %p\n' 2>/dev/null | 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 pipe this directly to rm until owners, retention rules, and open-file state are understood.
Expected output
Old candidate files with modification date, byte size, and path.
System impact
Read-only, can be slow. Nothing changes. The command prints only candidate files older than the threshold.
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 before manual cleanup of upload, export, cache, or temp paths where age matters.
When not to use it
Do not pipe this directly to rm until owners, retention rules, and open-file state are understood.
Recovery / rollback
No undo needed because the command only prints candidates.
next steps
Related commands
Rank Old Cleanup Candidates by Size
The oldest file is not always the file that buys back meaningful space.
find /var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' 2>/dev/null | sort -nr | head
Review Log Files Before Cleanup
Before truncating logs, prove which log files are large and how old they are.
find /var/log -xdev -type f -printf '%10s %TY-%Tm-%Td %p\n' 2>/dev/null | sort -nr | head -50
Summarize Cache File Ages
Cache cleanup is safer when you know whether files are stale or still active.
find /var/cache -xdev -type f -printf '%TY-%Tm-%Td\n' 2>/dev/null | sort | uniq -c
Exclude the Current Release from Cleanup
Release cleanup should prove what current points to before listing old directories.
current=$(readlink -f /home/deploy/current); find /home/deploy/releases -mindepth 1 -maxdepth 1 -type d ! -samefile "$current" -printf '%TY-%Tm-%Td %p\n' 2>/dev/null | sort
Find Directories Burning Inodes
Inode cleanup starts by finding the directory with too many files.
find /var/cache -xdev -type f -printf '%h\n' 2>/dev/null | sort | uniq -c | sort -nr | head
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.
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.