码迷,mamicode.com
首页 > 其他好文 > 详细

7>>monitor-disk

时间:2015-06-06 00:27:19      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:

#!/bin/bash
#
#top 10
#Big_USERS - find big disk space users in various directories
##############################################################
#Parameters for Script
#
CHECK_DIRECTORIES=" $HOME" #directories to check
#
##############################################################
#
########### Main Script #####################################
#
DATE=$(date ‘+%m%d%y‘) #Date for report file
#
exec > disk_space_$DATE.rpt #Make report file Std Output
#
echo "Top Ten Disk Space Usage" #Report header for whole report
echo "for $CHECK_DIRECTORIES Directories"
#
for DIR_CHECK in $CHECK_DIRECTORIES #loop to du directories
do
echo ""
echo "The $DIR_CHECK Directories:" #title header for each directories
#
#Create a listing of top ten disk space users
du -S $DIR_CHECK 2>/dev/null | #‘S‘: make a total than ‘s‘.
sort -rn | #rank with figure(n) and big is top(r).
sed ‘{11,$D;=}‘ |
sed ‘N;s/\n/ /‘ |
gawk ‘{printf $1 ":" "\t" $2 "\t" $3 "\n"}‘ #‘\t‘ is table-make mark which equal a tab(there).
#
done
#

7>>monitor-disk

标签:

原文地址:http://www.cnblogs.com/wyw248325496/p/4555791.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!