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.
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.)
Is there a way to configure JetS3t in a way that causes it to clean up after itself?
Thanks!
I came up with an inelegant, but working solution. I simply added a cron job that periodically runs the following command:
find /tmp/*tmp -amin +10 -exec rm -f {} \;
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.
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.