By using AWS re:Post, you agree to the Terms of Use

/TMP lifespan Linux/2.8.8



What age do files in the /TMP directory have to be before they are deleted? Where can I find this setting? I'd like to use the instance's tiny, included 8GB SSD drive and skip EBS, but some steps will have to be taken if the /TMP content sticks around for many hours or even days.

Ideally it would clear things our every few hours, or even check on the percentage of drive space remaining.


asked 3 years ago3 views
1 Answer

I used Touch to create files from days to years old, and after one day the /TMP directory was unchanged. I also did a quick check of the cron files and didn't see anything related to /TMP. Therefore, /TMP files likely stick around until the instance reboots. This means that you could use up all your instance's disk space unless you are careful, and never have a process crash. This seems to be a dangerous design.

touch -d "2020-01-28 12:12:12.000000000 +0530" test01.txt

I created my own temp directory at /mnt/tmp, and a cron that runs every hour to remove files over an hour old. This will be my safety net in case something unexpected happens.

.ebextensions > 01_setup.config
  "commands": {
    "01_create_tmp_folder": {
      "command": "mkdir -p /mnt/tmp"
    "02_set_tmp_folder_permission": {
      "command": "chmod 777 /mnt/tmp"
  "files": {
    "/etc/cron.hourly/GC": {
	"group": "root",
	"owner": "root",
	"mode": "000777",
	"content": "#!/bin/bash -e\ncd /mnt/tmp\nfind . -mmin +70 -delete\nexit 0\n"

Within /mnt/tmp, running "df -h ." confirmed that I had access to the increased instance store space.

Also, it turns out that only very large instances have a small SSD instance store included, default instance stores in the standard case is EBS Only.


answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions