This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
limit=92 | |
dir=/home/bfdz/rtorrent/downloads/ | |
v_mail= | |
log=/var/log/check_size.log | |
flag=0 | |
while [ 1 ] | |
do | |
v_size=$(df / | grep / | awk '{print $5}' | cut -d '%' -f 1) | |
if [ $v_size -ge $limit ] && [ $flag -ne 1 ]; then | |
chmod 555 $dir | |
echo Lock_the_directory:$dir >> $log && date >> $log | |
echo "盒子的使用空间超过 $limit%,目录 $dir 已禁止写入." | mail -s "=?UTF-8?B?`echo 盒子剩余空间不足 | base64`?=" $v_mail | |
flag=1 | |
fi | |
if [ $v_size -lt $limit ] && [ $flag -ne 0 ]; then | |
chmod 775 $dir | |
flag=0 | |
fi | |
sleep 30 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment