This commit is contained in:
xyj 2023-12-02 18:41:51 +08:00
parent 12084760b5
commit 26ec4bf098
1 changed files with 19 additions and 0 deletions

19
delete_than24.sh Executable file
View File

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