我在谷歌云存储中有一个存储桶。我在存储桶中有一个 tmp 文件夹。每天在此目录中创建数以千计的文件。我想每天晚上删除超过 1 天的文件。我在 gsutil 上找不到这个工作的论据。我不得不使用一个经典而简单的 shell 脚本来做到这一点。但是文件删除速度非常慢。
我在文件夹中积累了 650K 个文件。必须删除其中的 540K。但是我自己的 shell 脚本工作了 1 天,只能删除 34K 文件。
gsutil 生命周期功能无法完全满足我的要求。他正在清理整个桶。我只想定期删除某个文件夹底部的文件..同时我想更快地进行删除。
我愿意接受您的建议和帮助。我可以使用单个 gsutil 命令执行此操作吗?或不同的方法?
我为测试创建的简单脚本(我准备临时删除批量文件。)
## step 1 - I pull the files together with the date format and save them to the file list1.txt.
gsutil -m ls -la gs://mygooglecloudstorage/tmp/ | awk '{print $2,$3}' > /tmp/gsutil-tmp-files/list1.txt
## step 2 - I filter the information saved in the file list1.txt. Based on the current date, I save the old dated files …Run Code Online (Sandbox Code Playgroud)