Score:2

If `/tmp` is a symbolic link, it isn't wiped on reboot

es flag

On Ubuntu Server 22.04, I have an SSD mounted on /scratch. I replaced /tmp with a symbolic link to /scratch/tmp so that temporary files are stored on the SSD:

$ ls -l /tmp
lrwxrwxrwx 1 root root 12 Jan 13 16:22 /tmp -> /scratch/tmp

This seems to work fine with one snag: the contents of /tmp are no longer deleted on a reboot, as I expect them to be. How can I make this happen?

Score:4
vn flag

Temp files are cleaned in Ubuntu by systemd-tmpfiles and the related service /lib/systemd/system/systemd-tmpfiles-clean.service, and the configuration for said files can be configured inside /etc/tmpfiles.d/*.conf (also see this answer).

To include the directory you describe, create a config file:

sudo touch /etc/tmpfiles.d/scratch-tmp.conf

And then include this content in it:

# Type  Path         Mode User Group Age Argument
  e     /scratch/tmp -    -    -     20m

The e type defines that this is a "marked" directory that already exists, but should be cleaned. An age setting of 20m will clean all files more than 20 minutes old (see explanation below).

If the type is d, the directory will be created if it doesn't exist, and cleaned up on reboot and each day.

Be aware that the timer triggering the service (found at /lib/systemd/system/systemd-tmpfiles-clean.timer) is set to run 15 minutes after boot, so you won't see the actual effects at reboot until after 15 minutes uptime.

Please see the manpage for tmpfiles.d for more information.

ru flag
Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/142386/discussion-on-answer-by-artur-meinild-if-tmp-is-a-symbolic-link-it-isnt-wip).
I sit in a Tesla and translated this thread with Ai:

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.