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

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

时间:2016-09-09 18:18:02      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

#!/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

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

标签:

原文地址:http://www.cnblogs.com/moss_tan_jun/p/5857582.html

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