/tmp automatic cleanup

Source: Internet
Author: User
Tags volatile
CentOS7/tmp directory automatic cleanup rules

CentOS6 the following systems (including) use Watchtmp + cron to achieve the effect of scheduled cleanup of temporary files, which changed in CentOS7, under CentOS7, the system uses SYSTEMD management of volatile and temporary files, related to the system services have 3:

Systemd-tmpfiles-setup.service  : Create Volatile Files and directories
Systemd-tmpfiles-setup-dev.service:create static device nodes In/dev
systemd-tmpfiles-clean.service:cleanup of Temporary directories

The relevant configuration file also has 3 places:

/etc/tmpfiles.d/*.conf
/run/tmpfiles.d/*.conf
/usr/lib/tmpfiles.d/*.conf

The clean-up rule of the/TMP directory depends primarily on the settings of the/usr/lib/tmpfiles.d/tmp.conf file, with the default configuration:

# This file was part of  Systemd.
#
#  systemd is free software, you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General public License
as published by #  the free software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# See TMPFILES.D (5) For details

# Clear TMP directories separately, to make them easier to override
V/tmp 1777 root root 10d           #   clean up directories and files from/tmp 10 days ago
v/var/tmp 1777 root root 30d       #   Clean/var/tmp directories and files 30 days ago

# Exclude namespace mountpoints created with Privatetmp=yes
x/tmp/systemd-private-%b-*
x/tmp/ Systemd-private-%b-*/tmp
x/var/tmp/systemd-private-%b-*
x/var/tmp/systemd-private-%b-*/tmp

We can configure this file, for example, if you don't want the system to automatically clean up directories that start with Tomcat in/TMP, add the following to the configuration file:

x/tmp/tomcat.*
Therefore, the data is not saved in/tmp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.