Linux under TMP directory delete rule

Source: Internet
Author: User
Tags tmp folder


We know that in the Linux system in the/TMP folder inside the file will be emptied, as to how long to be emptied, how to empty, may not have a lot of knowledge, so, today we will analyze one of these two problems.

In the rhel\centos\fedora\ system (This experiment was conducted in RHEL6)

Take a look at Tmpwatch this command, his role is to delete files that are not used for a period of time (removes files which haven ' t been accessed for a period of the times). The specific usage is not much to say, interested in self-study. We mainly look at the scheduled task files associated with this command.

He's/etc/cron.daily/tmpwatch, and we can look at the contents of this file.

#! /bin/shflags=-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_* '  10d /tmp/ usr/sbin/tmpwatch  "$flags"  30d /var/tmpfor d in /var/{cache/man,catman}/{cat? X11r6/cat?,local/cat?};  do    if [ -d  "$d"  ]; then         /usr/sbin/tmpwatch  "$flags"  -f 30d  "$d"     fidone 

This script is carefully analyzed to understand that the first line is equivalent to a tag (parameter), the second line is for the/tmp directory in the excluded directory, the third row, this is the/tmp directory cleanup, the following is for the other directory cleanup, do not say.

We just came to see/usr/sbin/tmpwatch "$flags" 30d/var/tmp this line, the key is this 30d, is 30 days meaning, this decided 30 days to clean up the files not accessed by/TMP. If you want to clean up a day, change the 30d to 1d. This you know ... Ha ha!

But there is a problem to note, if you set a shorter time to clean up, say 30 minutes, 10 seconds and so on, you can set in this file, but you will find that re-computer, he does not clean the contents of the/tmp folder, this is why? This is tmpwatch his location, his upper-level directory is/etc/cron.daily/, and this directory is the day to perform a scheduled task, so that you set a shorter time than the day, he will not work. That's clear.

So the conclusion is: in RHEL6, the default time limit for the system to automatically clean the/tmp folder is 30 days.

Reprint: http://www.cnblogs.com/hnrainll/archive/2011/06/08/2074976.html

This article is from the "Potato" blog, please be sure to keep this source http://zhaoyulin.blog.51cto.com/11665101/1882029

Linux under TMP directory delete rule

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.