0

Random curiosity had me look up when exactly /tmp was cleared, to discover that most OS do it at shutdown or boot up. I had always thought it was more of a "whenever we need to reclaim space" logic.

This makes me wonder about all my cloud VMs, when are their /tmp folders cleared? Generally cloud VMs are never shut down, not unless you have done some upgrade requiring it for some reason, even in that case now of days your probably just tossing an image on a new box rather then upgrading the current one. I've had VMs that were running for well over half a year straight and likely will keep running longer.

On these boxes will /tmp just keep building up? If I have a few programs that leave junk in /tmp intermittently will my VM randomly go down in 2 years because it ran out of space?

If the question is too generic lets ask specifically about redhat/centos vms on ECS, just because it seems like the most common cloud VM out there, and the one I personally use.

dsollen
  • 103
  • 1
  • 5
  • 1
    Best practice involves you implementing a monitoring system which monitors disk space in addition to all of the other standard system resource items. – EEAA May 26 '17 at 18:32
  • 1
    Well-behaved applications that use /tmp should tidy up after themselves, just as they do with any other resource they use (e.g. network sockets). – Pak May 26 '17 at 18:33
  • "that don't get" Is there a word missing there, like "that don't get rebooted" – Barmar May 26 '17 at 18:44
  • CentOS6 and earlier would be the tmpwatch package, if installed. CentOS7 and later would be systemd. [Programs must not assume that any files or directories in /tmp are preserved between invocations of the program.](http://www.pathname.com/fhs/pub/fhs-2.3.html#TMPTEMPORARYFILES) – Aaron May 26 '17 at 21:54
  • This is kind of a duplicate of [when does tmp get cleared](https://serverfault.com/questions/377348/when-does-tmp-get-cleared). Short answer: There should be a `cronjob` or systemd `service` to clean up `/tmp`. – Henrik Pingel May 27 '17 at 07:22

0 Answers0