码迷,mamicode.com
首页 > 系统相关 > 详细

linux之tmpwatch命令

时间:2015-04-10 15:09:48      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:

系统使用时间长后会产生临时文件(/tmp下),需要清理。但清理的时候不推荐使用rm -rf。这样有时会引起程序的僵死。

tmpwatch的说明:

[root@AY121231034820cd91077 ~]# tmpwatch
tmpwatch 2.9.16 - (C) 1997-2009 Red Hat, Inc. All rights reserved.
This program may be freely redistributed under the terms of the
GNU General Public License version 2.

tmpwatch [-u|-m|-c] [-MUadfqtvx] [--verbose] [--force] [--all] [--nodirs] [--nosymlinks] [--test] [--quiet] [--atime|--mtime|--ctime] [--dirmtime] [--exclude <path>] [--exclude-user <user>] <hours-untouched> <dirs>

 

简介 :
tmpwatch 工具从指定的目录中递归地搜索,并删除在指定时间段内没有被访问的文件。tmpwatch 一般被用来清扫那些用来临时驻留文件的目录(譬如,/tmp)tmpwatch 忽略符号链接,它不会切换文件系统,而且只删除空目录和常规文件。

语 法:tmpwatch [-afqv][--test][超期时间][目录...] 

补充说明:执行tmpwatch指令可删除不必要的暂存文件,您可以设置文件超期时间,单位以小时计算。 

参数: 
-a或--all  删除任何类型的文件。 
-f或--force  强制删除文件或目录,其效果类似rm指令的"-f"参数。 
-q或--quiet  不显示指令执行过程。 
-v或--verbose  详细显示指令执行过程。 
-test  仅作测试,并不真的删除文件或目录

实例: sudo /usr/sbin/tmpwatch -afv 4 /tmp (清除/tmp下四小时以内没有使用的文件,并将结果输出)。

实例如下:

removing file /tmp/.ICE-unix/sess_25593dd8b8bed7870df27162b7be5125
removing file /tmp/.ICE-unix/sess_a0179d8a297cfd463b5fac7fd6efc97c
removing file /tmp/.ICE-unix/sess_6fb81c6b2234f6adc3fbe9557ac713d6
removing file /tmp/.ICE-unix/sess_6aadb21e0efe642e5c4a71f01e215865
removing file /tmp/.ICE-unix/sess_99d178821da1c33f5eae0511e672d30c
removing file /tmp/.ICE-unix/sess_433ca52b1c31b9af65d373d75890ceb7
removing file /tmp/.ICE-unix/sess_d4f9c6129bf2bb1d81398500ac5a569e
removing file /tmp/.ICE-unix/sess_7d29f5d3c259f1c6c4bedde9f975f6c9
removing file /tmp/.ICE-unix/sess_54c5baab9a157b9c613a38852ebf4397
removing file /tmp/.ICE-unix/sess_b2ac522cec3561e8d4c8172cdd408ae3
removing file /tmp/.ICE-unix/sess_9f2de1c14f60637324317cf515b99952
removing file /tmp/.ICE-unix/sess_db09a1bc04b65b08b35ab5a4787b7efe
removing file /tmp/.ICE-unix/sess_599d3263d6bf162b136784fd682d30cc
removing file /tmp/.ICE-unix/sess_2b49e884ad6f741a843c3fa237bf74f2
removing file /tmp/.ICE-unix/sess_e5d55bfa44d8962eba04f4e57d8d53f5
removing file /tmp/.ICE-unix/sess_8f493b6e85505169cafc33c8a3193493
removing file /tmp/.ICE-unix/sess_108b66b39811a985177b2ef1e4bf8d30
removing file /tmp/.ICE-unix/sess_69327aaafc1dedc20e4b8bea4115850c
removing file /tmp/.ICE-unix/sess_50626890a77806861675b031e1f8cfa1
removing file /tmp/.ICE-unix/sess_03e670ba79e12a86190645ce52bf3c43
removing file /tmp/.ICE-unix/sess_fb0db280a802e7b824d4d984557eb566
removing file /tmp/.ICE-unix/sess_a0f732bc28ed00e5bce03ca52ff9a143
removing file /tmp/.ICE-unix/sess_d5490bc5f57098d4ac13e160c9fc179d
removing file /tmp/.ICE-unix/sess_d042ffcea88c97681b9acf59e1b36965
removing file /tmp/.ICE-unix/sess_7834543a2e401f1efff4943eae4da14b

 

linux之tmpwatch命令

标签:

原文地址:http://www.cnblogs.com/yiluxiuxing/p/4414303.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!