sindresorhus / tempy

Get a random temporary file or directory path
MIT License
423 stars 26 forks source link

Where did you find that OS will cleanup tmp dir? #4

Closed gugu closed 5 years ago

gugu commented 6 years ago

The operating system will clean up when needed. No point in us wasting resources and adding complexity.

  1. Most linux distros cleanup tmp on reboot. But if system does not make reboot, tmp is not cleared
  2. Docker has no ability to run periodic cleanup script at all

Here is the example:

tmpfs            10M     0   10M   0% /home/gugu/test
gugu@container:~/test$ fallocate -l 1M t1
gugu@container:~/test$ fallocate -l 1M t2
gugu@container:~/test$ fallocate -l 1M t3
gugu@container:~/test$ fallocate -l 1M t4
gugu@container:~/test$ fallocate -l 1M t5
gugu@container:~/test$ fallocate -l 1M t6
gugu@container:~/test$ fallocate -l 1M t7
gugu@container:~/test$ fallocate -l 1M t8
gugu@container:~/test$ fallocate -l 1M t9
gugu@container:~/test$ fallocate -l 1M t10
gugu@container:~/test$ fallocate -l 1M t11
fallocate: fallocate failed: No space left on device
gugu@container:~/test$
sindresorhus commented 6 years ago

macOS: https://superuser.com/a/187105/6877

gugu commented 6 years ago

Probably it is better to replace:

The operating system will clean up when needed. No point in us wasting resources and adding complexity.

with:

macOS will clean up unused files in three days. No point in us wasting resources and adding complexity.

I spent 10 minutes reading docs to prove it is not correct. Other people will just trust this phrase. Your module generates filename so it is okay to not to write unlink function there. But this phrase is misleading

deevus commented 5 years ago

I'm using tempy in AWS Lambda and it's quite useful. However I have to clean up after myself manually, since the storage in Lambda is only 512MB and can get used up quite quickly with subsequent invocations of the same execution context.

It would be nice to have a cleanup method.