In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to automatically clean up the tmp directory in Linux, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
In the Linux system, the files under the / tmp folder will be cleaned and deleted. How do you set the rules for file cleaning? Take Redhat as an example, this is mainly because the tmpwatch command is called in the job to delete files that have not been accessed for a while.
So what is tmpwatch? Actually, tmpwatch is a command or a package. As shown below
Tmpwatch- removes files which haven't been accessed for a period of time [root@DB-Server ~] # rpm-qa | grep tmpwatch tmpwatch-2.9.7-1.1.el5.5 [root@DB-Server ~] # whereis tmpwatch tmpwatch: / usr/sbin/tmpwatch / usr/share/man/man8/tmpwatch.8.gz [root@DB-Server ~] # file / usr/sbin/tmpwatch / usr/sbin/tmpwatch: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV) For GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped [root@DB-Server ~] #
`
With regard to the parameters of the tmpwatch command, different versions may vary, with TMPWATCH (8) under Red Hat Enterprise Linux Server release 5.7as the column below
Function:
Delete files that have not been accessed for a period of time.
Parameters:
-u refer to the * access time of the file, that is, the * access time. Default option. Can be viewed through ls-lu.
-m refers to the * modified time of the file, that is, the * modification time. It can be viewed through ls-l.
-c refer to the-ctime time of the file. The condition of ctime update is to write, change owner and permission. Can be viewed through ls-lc.
-M deletes the directory according to the modification time of the directory instead of the access time.
-a Delete all types of files. Including catalog and symbolic links
-d-- nodirs excludes directory files, even if they are empty.
-d-- nosysmlinks excludes symbolic links type files.
-f forces the deletion of files that root does not have write permission to. Such as root's readonly file.
-Q reports only error messages.
-x / PATH excludes a specific directory, that is, does not delete files in that subdirectory.
"- U user_name excludes files that belong to a specific user, that is, does not delete files for that user."
-v shows the deletion process. The default is not to show what files have been deleted, just delete them.
-t is used for testing, does not really delete the file, and shows the process of deleting the file.
-d does not delete the subdirectories in the files, but the files in the subdirectories will still be deleted.
Parameter plus time. Default is hours. You can also use 30 days for 30 days, but some versions only support hours. After the time is the directory to be checked. Multiple directories can be separated by spaces. As shown below, 720 hours ~ = 30 days.
[root@DB-Server ~] # more / 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?} Do if [- d "$d]; then / usr/sbin/tmpwatch" $flags "- f 720" $d "fi done [root@DB-Server ~] #
If you want to change the mandatory deletion of files that have not been accessed for 30 days to 7 days, you only need to change the 720 to 189 in "/ usr/sbin/tmpwatch" $flags "720 / var/tmp" and "/ usr/sbin/tmpwatch" $flags "- f 720" $d ".
The above is how to automatically clean up the tmp directory in Linux. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.