Quick Linux Tip #80:
Question: My server ran out of disk. Which files grew the most in the last 24 hours?
Try: sudo find / -type f -mtime -1 -size +100M -exec ls -lah {} \; 2>/dev/null
Info: Uses -mtime -1 to target files modified within the last 24 hours and -size +100M to isolate large files. Redirecting errors with 2>/dev/null keeps permission-denied messages out of the results.
Examples:
- $
sudo find / -type f -mmin -60 -size +50M 2>/dev/null# Files >50 MB modified in the last 60 minutes - $
sudo du -Sh /var/log/* | sort -rh | head# Find the largest log files and directories - $
sudo find /var -type f -size +1G 2>/dev/null | xargs -I {} du -h {}# Find files larger than 1 GB
Note: The -Sh flags in du separate subdirectory totals to help pinpoint runaway logs quickly, such as systemd journal files, MySQL tables, and Nginx access logs.
Leave a Reply