Skip to content

Instantly share code, notes, and snippets.

@BFDZ BFDZ/check_size.sh
Last active Nov 21, 2017

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.