Centos – How to configure Fedora / RedHat / CentOS to delete files in /tmp on boot

centosfedoraredhat

How can you configure Fedora / RedHat / CentOS systems to delete files in /tmp on boot like Debian and Ubuntu?

Best Answer

On recent versions (CentOS 7, Fedora 23), add a .conf file to "/usr/lib/tmpfiles.d", the name is irrelevant, name it boot.conf for example, but it has to be a different file than tmp.conf, there cannot be two entries for the same directory in a single file. Add the the following line:

R! /tmp 1777 root root ~0