根据所剩磁盘存储空间的百分比
#!/usr/bin/env bash
#-*- coding:utf-8 -*-
function help(){
printf "Usage: \n"
printf " python mem.py 50(百分比)\n"
}
function create_file(){
unit=$1
count=$2
newdirname="diskdir"
cd /data1/minisearch/
[ ! -d ${newdirname} ] && mkdir ${newdirname}
cd ${newdirname}
for i in `seq 1 ${count}`;do
dd if=/dev/zero of=zeroFile${i} bs=1${unit} count=5 >/dev/null 2>&1
done
sleep 1
cd /data1/minisearch/diskdir/
for j in `seq 1 ${count}`;do
rm -f zeroFile${j}
done
}
create_ration=$1
if (( 1 <= ${create_ration} && ${create_ration} <= 99 ));then
allfreesize=$(echo `df -h | grep "data1" | awk '{print $4}'` | sed 's/[A-Z]//g')
create_size=$((${allfreesize}*${create_ration}/100))
c=$((${create_size}/5))
while true
do
create_file "G" ${c}
sleep 2
done
else
help
fi
网友评论