Plesk

Too many files in directories like /tmp/systemd-private- cause server crash due to lack of disk space

Symptoms

Cause

The PrivateTmp systemd feature is enabled for the services mentioned in the subdirectory names of /tmp. Configuring a systemd service with PrivateTmp=true leads to the fact that the service starts using a private tmp directory and creates subdirectories within the /tmp server directory that store its temporary files. There are a lot of files in the created subdirectories and this causes lack of disk space.

Resolution

Solution 1

1. Log into your server via SSH

2. Configure the temporary file rotation to happen as often as you need it to by opening the file
/usr/lib/tmpfiles.d/tmp.conf
with your favorite command-line text editor.

3. When you open the file, you will see lines that are similar ot the following:

#Clear tmp directories separately, to make them easier to override
#Type Path Mode User Group Age Argument
v /tmp 1777 root root 10d
v /var/tmp 1777 root root 30d
3. Save the changes

Note: The configuration file has a special syntax. Every line is a rule. Each line in the tmpfiles.d configuration file is separated by tabs or spaces into seven columns that define a rule. More information related to the possible configurations is available here.

Solution 2

Disable the PrivateTmp systemd feature for the service (example, for MariaDB):

  1. Check which services have
    PrivateTmp
    set to
    true
    :

    # grep -R PrivateTmp /etc/systemd/
    /etc/systemd/system/multi-user.target.wants/named-chroot.service:PrivateTmp=false
    /etc/systemd/system/multi-user.target.wants/php-fpm.service:PrivateTmp=true
    /etc/systemd/system/multi-user.target.wants/httpd.service:PrivateTmp=true
    /etc/systemd/system/multi-user.target.wants/mariadb.service:PrivateTmp=true

  2. Stop the service:

    # systemctl stop mariadb

  3. Change
    PrivateTmp
    value to
    false
    in the file
    /etc/systemd/system/multi-user.target.wants/mariadb.service

  4. Reload
    systemd
    :

    # systemctl daemon-reload

  5. Start
    mariadb
    :

    # systemctl start mariadb

Exit mobile version