首页 > 代码库 > 创造加了日期的前十名磁盘空间用户报告的脚本

创造加了日期的前十名磁盘空间用户报告的脚本

#!/bin/bash
#Big_User - find big disk space users in various direcotries
#Parameters for Script
#
CHECK_DIRECTORIES="/var/log /home" #direcotries to check
#
######################Main Script###########################
#
DATE=`date +%m%d%y`               #Date for report file
exec > space_file_$DATA.rpt
#
#
echo "Top Ten Disk Space Usage"   #Report header for whole report
echo "for $CHECK_DIRECTORIES Direcotries"
#
for DIR_CHECK in $CHECK_DIRECTORIES #loop to du directories
do
       echo ""
       echo "The $DID_CHECK Directory:" #Title header for each direcotry
#
#Create a listing of top ten disk space users
       du -S $DIR_CHECK 2>/dev/null|sort -rn|sed ‘{11,$D;=}‘|sed ‘N;s/\n/ /‘|gawk ‘{printf $1":""\t" $2"\t" $3"\n"}‘
#
done
exec > /tmp/test.txt

创造加了日期的前十名磁盘空间用户报告的脚本