This commit is contained in:
xyj 2023-12-11 09:54:02 +08:00
parent 094a9f520e
commit 8435c1337f
1 changed files with 4 additions and 4 deletions

View File

@ -5,14 +5,14 @@ folder="/home/pi/mp4"
# 进入文件夹 # 进入文件夹
cd $folder cd $folder
# 获取文件夹的大小 # 获取文件夹的大小
size=$(du -sh "$folder" | awk '{print int($1/1024)}') size=$(du -sh "$folder" | awk '{print int($1)}')
while [[ $size -gt 20 ]] while [[ $size -gt 50 ]]
do do
# 获取最早创建的文件 # 获取最早创建的文件
oldest_file=$(ls $folder -tr | head -1 | xargs) oldest_file=$(ls $folder -tr | head -1 | xargs)
rm -f $oldest_file rm -f $oldest_file
size=$(du -sh "$folder" | awk '{print int($1/1024)}') size=$(du -sh "$folder" | awk '{print int($1)}')
if [[ $size -le 20 ]] if [[ $size -le 50 ]]
then then
exit 0 exit 0
fi fi