This commit is contained in:
xyj 2023-12-08 14:57:36 +08:00
parent beda12077b
commit 8c65af3332
1 changed files with 5 additions and 4 deletions

View File

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