红联Linux门户
Linux帮助

Linux临时文件的清理(转载)

发布时间:2007-11-27 12:41:59来源:红联作者:deepwhite
源自:http://hi.baidu.com/yangyingchao ... 3556519822edb8.html

系统使用时间长后会产生临时文件(/tmp下),需要清理。但清理的时候不推荐使用rm -rf。这样有时会引起程序的僵死。
推荐使用tmpwatch命令来进行清理。关于tmpwatch的说明如下:

名称 : tmpwatch
版本 : 2.8.4
发布号 : 5
所属组 : 系统环境/基础 源码包: tmpwatch-2.8.4-5.src.rpm
大小 : 13273 许可类型: GPL
摘要 : 根据文件被访问的时间来删除文件的工具。
简介 :
tmpwatch 工具从指定的目录中递归地搜索,并删除
在指定时间段内没有被访问的文件。tmpwatch 一般
被用来清扫那些用来临时驻留文件的目录(譬如,/tmp)
tmpwatch 忽略符号链接,它不会切换文件系统,而且
只删除空目录和常规文件。

语 法:tmpwatch [-afqv][--test][超期时间][目录...]
补充说明:执行tmpwatch指令可删除不必要的暂存文件,您可以设置文件超期时间,单位以小时计算。
参数:
-a或--all  删除任何类型的文件。
-f或--force  强制删除文件或目录,其效果类似rm指令的"-f"参数。
-q或--quiet  不显示指令执行过程。
-v或--verbose  详细显示指令执行过程。
-test  仅作测试,并不真的删除文件或目录
实例: sudo /usr/sbin/tmpwatch -afv 3 /tmp (清除/tmp下三小时以内没有使用的文件,并将结果输出)。
效果:
[size=2][yyc@localhost ~]$ sudo /usr/sbin/tmpwatch -afv 3 /tmp
removing file /tmp/mapping-yyc
removing file /tmp/orbit-yyc/linc-814-0-1bf6199e48d6e
removing file /tmp/orbit-yyc/linc-7ee-0-74c6cf6b5c2c6
removing file /tmp/orbit-yyc/linc-7fd-0-3ae286a04fa21
removing file /tmp/orbit-yyc/linc-854-0-4e3c22c96ddf
removing file /tmp/orbit-yyc/linc-798-0-1c90b9a4739a7
removing file /tmp/orbit-yyc/linc-7e9-0-56828c5c66be1
removing file /tmp/orbit-yyc/linc-815-0-1e0f6f36a2ee3
removing file /tmp/orbit-yyc/bonobo-activation-server-ior
removing file /tmp/orbit-yyc/linc-850-0-5c3b9d5470bfc
removing file /tmp/orbit-yyc/linc-803-0-5ee49981d2cee
removing file /tmp/orbit-yyc/linc-852-0-5c3b9d54bcd06
removing file /tmp/orbit-yyc/linc-83e-0-716284b294fae
removing file /tmp/orbit-yyc/linc-856-0-5c3b9d547287e
removing file /tmp/orbit-yyc/linc-81d-0-1e0f6f36e88f7
removing file /tmp/orbit-yyc/linc-7fa-0-6c21b504ee8e0
removing file /tmp/orbit-yyc/linc-7f9-0-577d962b48783
removing file /tmp/orbit-yyc/linc-7f6-0-1440368b7d5e4
removing file /tmp/orbit-yyc/linc-81a-0-200a47e1c1117
removing file /tmp/orbit-yyc/bonobo-activation-register.lock
removing file /tmp/orbit-yyc/linc-7f7-0-5950ba2b9774d
removing directory /tmp/orbit-yyc if not empty
removing file /tmp/.esd-500/socket
removing file /tmp/pulse-yyc/pid
removing file /tmp/pulse-yyc/native
removing file /tmp/keyring-Mf0bbZ/socket
removing file /tmp/.X0-lock
removing file /tmp/.X11-unix/X0
removing file /tmp/.ICE-unix/1944
removing file /tmp/ssh-RcIyLY1944/agent.1944
removing file /tmp/.gdmK8P41T
removing file /tmp/gconfd-yyc/lock/ior


[/size]
[attach]5595[/attach]

[ 本帖最后由 deepwhite 于 2007-11-27 12:48 编辑 ]
文章评论

共有 12 条评论

  1. 韩冬雪 于 2010-08-26 12:56:41发表:

    LZ不说 我还真不知道呢...好东西 有待实践和学习

  2. yanlong938 于 2010-08-18 10:01:03发表:

    学习了 。。。

  3. 水若凌 于 2010-08-18 08:53:00发表:

    。。。。。。。。。。。。。。。。。。。。。

  4. 水若凌 于 2010-08-18 08:52:55发表:

    。。。。。。。。。。。。。。。。。。。。。。。

  5. jihy 于 2010-08-17 17:51:40发表:

    顶了。

  6. 冰融 于 2010-08-13 15:03:16发表:

    这个命令还真不知道呢

  7. 难得悠哉 于 2010-08-13 12:49:52发表:

    好东西 谢了

  8. kamus001 于 2010-08-12 13:42:50发表:

    dddddddddddddddddddddddddddddddddddddd

  9. qyl68 于 2010-08-12 10:20:17发表:

    这个文件不用下载,里面的内容都已经贴出来了

  10. ldate911 于 2008-07-23 23:37:44发表:

    好像挺好用,要实践一下

  11. system32 于 2008-07-23 23:23:56发表:

    似乎挺有用.

  12. kemen 于 2007-11-27 15:59:53发表:

    ?了