Linux命令行与shell脚本编程大全 8.5分
读书笔记 为指定目录创建加了日期戳的前十名磁盘空间用户报告
超级露

# 为指定目录创建一个加了日期戳的前十名磁盘空间用户报告 #!/bin/bash # # Big Users - find big disk space users in various directories ############################################################## # Parameters for Script # CHECK_DIRECTORIES="/var/log /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 Directory:" #Title header for each directory # #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 #end of loop for du directories #

#添加到cron表中:15 7 * * 1 /home/user/Big_Users #该条目会在每周一早晨7:15运行这个脚本

0
《Linux命令行与shell脚本编程大全》的全部笔记 37篇
豆瓣
我们的精神角落
免费下载 iOS / Android 版客户端