Score:2

Why does a particular directory always exist in /tmp even after reboots?

lu flag

I am using Ubuntu 20.04.3. I remember in the past creating a directory /tmp/myWork. I usually work on that directory: downloading files, saving temporary files while working on some software, etc.

However, when I reboot my machine, that directory is always there but it's empty. I wonder why it doesn't get deleted when I reboot? why its content gets delete but not that directory itself?

Just in case the permission of the directory is important, I include it here:

ls -alF /tmp | grep myWork
drwx------  3 user user      4096 Jan  4 17:34 myWork/

Any ideas?

Edit:

Here is the output of df /tmp/myWork

Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sdb1      960379920 852343804  59181692  94% /

Edit2:

$ grep -F '17:34' /var/log/syslog

Jan  4 08:17:34 probook systemd[513982]: Started Application launched by gnome-shell.
Jan  4 08:17:34 probook PackageKit: resolve transaction /34190_abadddeb from uid 1000 finished with success after 598ms
Jan  4 17:34:07 probook gnome-shell[514206]: ../clutter/clutter/clutter-actor.c:10558: The clutter_actor_set_allocation() function can only be called from within the implementation of the ClutterActor::allocate() virtual function.
Jan  4 17:34:42 probook gnome-shell[514910]: [514911:514911:0104/173442.538073:ERROR:CONSOLE(1)] "[Shields]: Can't request shields panel data for tabId: 1155.  Error: No tab url specified", source: chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js (1)
Jan  4 17:34:42 probook gnome-shell[514910]: [514911:514911:0104/173442.538578:ERROR:CONSOLE(1)] "[Shields]: Can't request shields panel data for tabId: 1155.  Error: No tab url specified", source: chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js (1)

user535733 avatar
cn flag
It does get deleted when you reboot. And then it gets made anew by something in your boot sequence.
OK-Validation avatar
lu flag
@user535733: How do I check that? if possible.
OK-Validation avatar
lu flag
@user535733: I am not sure I understand your request. My question as stated in the post is to find why?
phunsoft avatar
cn flag
Can you edit your question and show output from `df /tmp/myWork`?
OK-Validation avatar
lu flag
@phunsoft: done!
OK-Validation avatar
lu flag
@user535733: That's your point of view. As a beginner why would you assume that I should ask such an advanced question like that. I will definitely accept an answer that explains how my assumption is wrong and how to find what's creating that directory.
OK-Validation avatar
lu flag
@user535733: My assumption is technically correct because why should one assume that something is deleted then get created when he can simply say why it didn't get deleted.
user535733 avatar
cn flag
The purpose of comments is to help you make your question clear and answerable. If you ask the wrong question, you are likely to be unsatisfied with the answers. We don't expect you to ask an first-time-perfect question. We do expect you to refine and improve your question as you learn more about the problem.
OK-Validation avatar
lu flag
@user535733: While I appreciate your input sorry to say that I don't agree, because I am looking from a beginner point of view (and that's the case for most people reaching this via search engine). I wouldn't assume that the directory is deleted then created that's a strong assumption that requires evidence itself.
OK-Validation avatar
lu flag
@phunsoft: Sorry I am not that familiar with such operation, I am afraid messing with my PC will let me regret and given that I have a very important presentation in my department.
user535733 avatar
cn flag
Moving on, your output's modification time for that directory is `Jan 4 17:34`. What was your system doing at that time?
OK-Validation avatar
lu flag
@user535733: I don't remember exactly but I clone and compile software there.
OK-Validation avatar
lu flag
@user535733: I am not familiar with that. I don't understand your point here assuming that I am already a linux guru. I am a simple student in philosophy deparatement who is not supposed to know this stuff
user535733 avatar
cn flag
Start by reading your /var/log/syslog file for that time. Beginners rarely "*clone and compile software*", so apologies if I have overestimated your skill level.
OK-Validation avatar
lu flag
@user535733: I have updated the post.
phunsoft avatar
cn flag
I've overlooked the fact that the `df` command output shows the mountpoint as `/`, not as `/tmp/myWork`. That makes my previous (now deleted) comment about editing `/etc/fstab` obsolete. The `/tmp`, and the `/tmp/myWork` directories are in your root file system. No temporary files system involved.
darth_epoxy avatar
nl flag
RedHat and CentOS clears the /tmp folder if the files are not accessed for 10 days. Fedora 18 onward the /tmp folder is mounted on the RAM (tmpfs) thus clears when system is powered off. I always thought that Ubuntu clears it on boot but perhaps it has works simular to the others?
darth_epoxy avatar
nl flag
if you have the brain for it read `man tmpfiles.d`
Score:3
us flag

The fate of /tmp contents following a reboot depends on a couple of things.

On a system which uses tmpfs for /tmp, /tmp is empty following each reboot because tmpfs does not persist across reboots (or even umount followed by mount). My Ubuntu 20.04.3 system does not use tmpfs for /tmp, and I did not override the default.

On a system with /tmp as a simple subdirectory of / (or as a mount point on a persistent file system), the contents of /tmp following a reboot depend on the configuration of systemd-tmpfiles.

My Ubuntu 20.04.3 system has the following lines in /usr/lib/tmpfiles.d/tmp.conf.

# Clear tmp directories separately, to make them easier to override
D /tmp 1777 root root -

man tmpfiles.d includes, the following description of the age field.

If omitted or set to "-", no automatic clean-up is done.

A simple way to rule out the possibility that something is creating the directory at boot time is to remove it manually and then reboot, but it seems more likely that the existing directory survives the reboot.

phunsoft avatar
cn flag
As per output from the `df /tmp/myWork` show in the Q, `/tmp` is *not* a tmpfs. That would leave the `systemd-tmpfiles` option you mention. But wouldn't this either delete *all* content, including the `myWork` subdirectory, or nothging?
OK-Validation avatar
lu flag
I keep re-reading your answer but unfortunately I don't understand what you're suggesting as solution to my question.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.