User Tools

Site Tools


largest_files

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
largest_files [2016/01/28 11:03] luke7858largest_files [2024/05/23 07:26] (current) – external edit 127.0.0.1
Line 8: Line 8:
 du -sh /home/rack du -sh /home/rack
 </sxh> </sxh>
 +\\
 +----------------------------------------------
 +=== NEW IMPROVED ===
 +
 +one-liner (also checked for open (Deleted) files).
 +\\
 +Change the "/" in filesystem="/" to analyse another filesystem
 +<sxh bash>
 +filesystem="/";BREAK="===============================================================";echo -ne "\n $BREAK \n \t Disk Usage for $filesystem $(date +'%F') \n $BREAK \n\n";df -h $filesystem; echo -e '\n\n Volume Group Usage: \n'; vgs $(df -h $filesystem | grep dev | awk '{print $1}'| cut -d\- -f1| cut -d\/ -f4); echo -e '\n'; echo -e "Largest Folders:\n"; du -xSk $filesystem | sort -rn | head -20|awk '{printf "%d MB\t%s\n",($1/1024),$NF}' && echo -e "\n\n"; echo -e "Largest Files:\n"; find $filesystem -mount -type f -ls|sort -rnk7 |head -20|awk '{printf "%d MB\t%s\n",($7/1024)/1024,$NF}';echo -e "\n\n Open Deleted Files:\n"  ;lsof | grep $filesystem | grep deleted| awk '{ if($7 > 1048576) print $7/1048576, "MB ",$9,$1 }' | sort -n -u | tail; echo -e "\n $BREAK"
 +</sxh>
 +\\
 +---------------------------------------------------
 +=== List Open Deleted Files ===
 +Print a list of all the deleted open files in MB:
 +<sxh bash>
 +lsof | awk '/REG/ && !/stat: No such file or directory/ && !/DEL/ {if ($NF=="(deleted)") {x=3;y=1} else {x=2;y=0}; {print $(NF-x) "  " $(NF-y) } }'  | sort -n -u  | awk '{ print $1/1048576, "MB ", $NF }' | tail -5 | head -5 ;
 +</sxh>
 +\\
 +------------------------------------------------
 Show a break down of the system usage: Show a break down of the system usage:
 <sxh bash> <sxh bash>
Line 30: Line 49:
    
 \\ \\
 +--------------------------------------------------
 === INODES === === INODES ===
  
largest_files.1453979013.txt.gz · Last modified: 2024/05/23 07:26 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki