我现在正在工作,我的上级要求我为红帽子服务器版编写/查找一个shell脚本来检查文件夹的大小,如果超过了一定的限制,它会发送一封电子邮件。在这里任何人都可以帮助我find或帮我创build一个这样的脚本?
我提前谢谢你,
Jayakrishnan T
你已经在运行Nagios了吗?
签出check_dirsize或check_filesize_dir:
如果你愿意的话,两者都可以很容易地适应用完cron。
#!/bin/bash DIR=/path/to/dir SIZE=10000 MAILADDR="[email protected]" if [ $(du -s $DIR | awk '{print $1}') -gt $SIZE ]; then echo "$DIR" | mail -s "Directory limit exceeded in $DIR" $MAILADDR fi
SIZE必须在字节中给出!
我会认为inotify-tools (1) inotify-tools在这里会有所帮助。