Using /dev/shm folder for pid files on RHEL6/CentOS6?

Boying asked:

RHEL7/CentOS7 has a dedicated folder: $XDG_RUNTIME_DIR (e.g. /run/user/1000) for pid files, that folder is a tmpfs. However RHEL6/CentOS6 does not have $XDG_RUNTIME_DIR.

RHEL6(also RHEL7) has a folder using similar type: /dev/shm. After some testing and searching on Internet, I realize it’s convenient place for IPC purpose, and also seems OK to put small pid files in it.

So the question is: Are there any drawbacks of using this folder for the pid files.

(Example of not using other folder like /tmp: there is a crontab job removes pid files every certain days causing service unstable)

Reference:

https://www.cyberciti.biz/tips/what-is-devshm-and-its-practical-usage.html
https://wiki.archlinux.org/index.php/tmpfs

My answer:


On RHEL 6, PID files are almost always in /var/run or a subdirectory thereof. This directory is only cleared at boot time. On RHEL 7, this directory is now /run and /var/run is symlinked to it for backward compatibility.

The directory you mention, $XDG_RUNTIME_DIR, is used by user processes, not system services.

You aren’t really meant to abuse /dev/shm for this though. This directory exists for processes which communicate via shared memory to provide a backing store.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.