tes
This commit is contained in:
parent
653e340758
commit
12084760b5
|
@ -1,8 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 设置文件保留时间为2天
|
||||
DAYS=2
|
||||
|
||||
# 使用find命令查找所有符合条件的文件
|
||||
find /home/pi/mp4 -type f -mtime +$DAYS -exec rm -f {} \;
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#!/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
|
||||
|
Loading…
Reference in New Issue