monitor disk
1 #!/bin/bash 2 # 3 #top 10 4 #Big_USERS - find big disk space users in various directories 5 ############################################################## 6 #Parameters for Script 7 # 8 CHECK_DIRECTORIES=" $HOME" #directories to check 9 # 10 ############################################################## 11 # 12 ########### Main Script ##################################### 13 # 14 DATE=$(date '+%m%d%y') #Date for report file 15 # 16 exec > disk_space_$DATE.rpt #Make report file Std Output 17 # 18 echo "Top Ten Disk Space Usage" #Report header for whole report 19 echo "for $CHECK_DIRECTORIES Directories" 20 # 21 for DIR_CHECK in $CHECK_DIRECTORIES #loop to du directories 22 do 23 echo "" 24 echo "The $DIR_CHECK Directories:" #title header for each directories 25 # 26 #Create a listing of top ten disk space users 27 du -S $DIR_CHECK 2>/dev/null | #'S': make a total than 's'. 28 sort -rn | #rank with figure(n) and big is top(r). 29 sed '{11,$D;=}' | 30 sed 'N;s/\n/ /' | 31 gawk '{printf $1 ":" "\t" $2 "\t" $3 "\n"}' #'\t' is table-make mark which equal a tab(there). 32 # 33 done 34 #