CentOS tmp directory automatic purge and Tmpwatch command __ operating system

Source: Internet
Author: User
TMP directory automatic purge and Tmpwatch command

Habitually put some temporary files in the TMP directory, so that it naturally deleted. At the same time, in order to ensure that the TMP directory is not full, the system by default the daily processing of the TMP directory files, the principle is to use the Tmpwatch. This feature is not installed in the case of a minimal installation of the system. Installation:

# yum Install tmpwatch.x86_64

After installation, a Tmpwatch file is generated in the/etc/cron.daily/directory. The contents are as follows:

# Cat/etc/cron.daily/tmpwatch
Flags=-umc
/usr/sbin/tmpwatch "$flags"-x/tmp/. X11-unix-x/tmp/. Xim-unix \
-x/tmp/.font-unix-x/tmp/. Ice-unix-x/tmp/. Test-unix \
-X '/tmp/hsperfdata_* ' 240/tmp
/usr/sbin/tmpwatch "$flags" 720/var/tmp
For D In/var/{cache/man,catman}/{cat?,x11r6/cat?,local/cat?}; Todo
If [-D "$d"]; Then
/usr/sbin/tmpwatch "$flags"-F 720 "$d"
Fi
Done

As you can see from the code, the TMP directory deletes files that have not been accessed for 240 hours.

The Tmpwatch tool recursively searches for and deletes files that have not been accessed for some time in the specified directory from the specified directory.

Tmpwatch parameter Description:

-U,--atime deletes files based on access time, default.
-M,--mtime deletes files based on modified time.
-C,--ctime deletes files based on creation time, for directories, based on Mtime.
-M,--dirmtime deletes the directory based on the directory's modified time instead of the access time.
-A,--all deletes all file types, not just plain files, symbolic links and directories.
-D,--nodirs does not attempt to delete the directory, even if it is an empty directory.
-D,--nosymlinks does not attempt to delete the symbolic link.
-F,--force forced deletion.
-Q,--quiet only reports error messages.
-S,--fuser try to use the "fuser" command if the file is already open before deleting it. is not enabled by default.
-T,--test only for testing and does not really delete files or directories.
-U,--exclude-user=user does not delete who belongs to the file.
-V,--verbose print details.
-X,--exclude=path excludes the path, and if the path is a directory, all of the files it contains are excluded. If the path does not exist, it must be an absolute path that does not contain a symbolic link.
-X,--exclude-pattern=pattern excludes the path under a rule.
Related Article

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.