Why are the contents of /dev/shm/ is being removed automatically

From my answer:

After hours of searching and reading, I found the culprit. It's a setting for systemd. The /etc/systemd/logind.conf contains default configuration options, with each of them commented out. The RemoveIPC option is set to yes by default. That option tells systemd to clean up interprocess communication (IPC) for "user accounts" who aren't logged in. This does not affect "system accounts"

In my case, the files and directories were being created for a user account, not a system account.

There are two possible solutions:

  1. Create the files with/for a system user -- a user created with the system option (adduser -r or adduser --system)
  2. Edit /etc/systemd/logind.conf, uncomment the line RemoveIPC=yes, change it to RemoveIPC=no, save, and reboot the system

In my case, I went with option #2 because the user was already created.

References:

  • RemoveIPC prematurely removes IPC segments
  • Change default value of RemoveIPC in logind.conf
  • PostgreSQL: Systemd
  • Oracle: 3.5 Database Installation and Operation Fails if RemoveIPC=yes Is Configured for systemd

Tags:

Linux

Ssh