系统管理:磁盘与文件定位脚本优化
1. 报告磁盘占用大户
在系统管理中,磁盘配额管理是一项重要任务。为了方便管理员管理磁盘配额,可通过扩展 fquota 来直接向占用过多磁盘空间的用户发送电子邮件警告。以下是实现该功能的 diskhogs 脚本:
#!/bin/bash
# diskhogs--Disk quota analysis tool for Unix; assumes all user
# accounts are >= UID 100. Emails a message to each violating user
# and reports a summary to the screen.
MAXDISKUSAGE=500
violators="/tmp/diskhogs0.$$"
trap "$(which rm) -f $violators" 0
for name in $(cut -d: -f1,3 /etc/passwd | awk -F: '$2 > 99 { print $1 }')
do
/bin/echo -n "$name "
# You might need to modify the following list of directories to match the
# layout of your disk. The most likely change is from /Users to /home.
find / /usr /var /Users -xdev -user $name -type f
超级会员免费看
订阅专栏 解锁全文
3077

被折叠的 条评论
为什么被折叠?



