的JetS3t填补了我的/ tmp目录。我应该如何删除旧文件?我的、文件、目录、JetS3t

2023-09-11 10:12:08 作者:兩看兩相厭

我开发使用的JetS3t从S3恢复文件在Linux上某些HTTP服务器软件。这些文件都是围绕5MB。随着时间的推移,的JetS3t创建大量的在/ tmp目录下的* .tmp文件。

I'm developing some HTTP server software on Linux that uses JetS3t to retrieve files from S3. The files are all around 5MB. Over time, JetS3t creates a large number of *.tmp files in the /tmp directory.

但是,由于这是从未重新启动的服务器上所有运行时,文件永远不会扔掉。相反,他们最终填满根分区,引起了许多问题(例如丢弃HTTP连接,等等。)

However, since this is all running on a server that is never rebooted, the files never get thrown away. Instead, they eventually fill up the root partition, causing a number of problems (like dropped HTTP connections, etc.)

有没有一种方法来配置的JetS3t的方式,导致后自己清理?

Is there a way to configure JetS3t in a way that causes it to clean up after itself?

谢谢!

推荐答案

我想出了一个不雅的,但工作的解决方案。我只是简单地添加定期运行以下命令cron作业:

I came up with an inelegant, but working solution. I simply added a cron job that periodically runs the following command:

找到的/ tmp / * TMP -amin +10 -exec RM -f {} \;

基本上,查找定位所有的JetS3t的是被访问的至少10分钟前。tmp文件(感谢 -atime +10 ),然后将它们删除。

Basically, find locates all of JetS3t's tmp files that were accessed at least ten minutes ago (thanks to -atime +10) and then deletes them.

这模仿的 TM $ P $文件 tmpwatch present在某些系统上的行为。对于其他人使用这些应用程序,要小心,因为他们可能会促进某些 setuid的漏洞。我知道我的做法也可能会受到同样的漏洞,但现在我别无选择。

This mimics the behavior of tmpreaper or tmpwatch present on some systems. For others using these apps, beware, as they can facilitate some setuid exploits. I realize my approach may also be susceptible to the same exploits, but for now I have no choice.