半瓶内容

 results 1 - 1 of about 1 for 慎用rm命令清理文件释放空间. (0.330 seconds) 

慎用rm命令清理文件释放空间

用rm命令清理文件,有时候不能有效的释放空间,这是因为可能还有进程在使用该文件,文件句柄并没有释放。

前几天用rm清理了bdump目录下的几个很大的trace文件,就碰到了这个问题。

# df -g
Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/oraclelv     18.00      3.36   82%    63780     8% /u01

清理后以上的空间使用情况并没有变化。

Eygle的文章提到可以用lsof工具查找哪些进程在使用这些文件,但是我在AIX平台上安装并使用了lsof工具后,并没有找到相关信息:

# ./lsof /u01/admin/dr/bdump/dr_p001_467080.trc
lsof: status error on /u01/admin/dr/bdump/dr_p001_467080.trc: No such file or directory
lsof 4.77
latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
usage: [-?abhlnNoOPRstUvVX] [+|-c c] [+|-d s] [+|-D D] [+|-f[cfgGn]]
[-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [-m m] [+|-M] [-o [o]]
[-p s] [+|-r [t]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Use the ``-h'' option to get more help information.

尝试了几个命令都没有找到在使用删除的文件的进程:

# ./lsof +L1
COMMAND    PID   USER   FD   TYPE DEVICE   SIZE/OFF NLINK  NODE NAME
oracle  176474 oracle    7u  VREG  10,12          0     0 11690 /u01 (/dev/oraclelv)
oracle  217384 oracle    7u  VREG  10,12          0     0 11681 /u01 (/dev/oraclelv)
oracle  258344 oracle    7u  VREG  10,12          0     0 11681 /u01 (/dev/oraclelv)

# ./lsof +d /u01/admin/dr/bdump
COMMAND    PID   USER   FD   TYPE DEVICE SIZE/OFF  NODE NAME
oracle  176474 oracle    2w  VREG  10,12 29387134 90518 /u01/admin/dr/bdump/dr_p016_176474.trc
oracle  176474 oracle    6w  VREG  10,12 64725204 44457 /u01/admin/dr/bdump/alert_dr.log
oracle  176474 oracle    8w  VREG  10,12 64725204 44457 /u01/admin/dr/bdump/alert_dr.log

# ./lsof|grep oracle
oracle    176474 oracle  cwd   VDIR              10,12               4096   195 /u01 (/dev/oraclelv)
oracle    176474 oracle    0r  VCHR                2,2                0t0   279 /dev/null
oracle    176474 oracle    1r  VCHR                2,2                0t0   279 /dev/null

# ./lsof +d /u01/admin/dr/bdump
COMMAND    PID   USER   FD   TYPE DEVICE SIZE/OFF  NODE NAME
oracle  176474 oracle    2w  VREG  10,12 29387134 90518 /u01/admin/dr/bdump/dr_p016_176474.trc
oracle  176474 oracle    6w  VREG  10,12 64726194 44457 /u01/admin/dr/bdump/alert_dr.log

对lsof不熟悉,也没有深究下去找那些进程,最后重启实例释放了空间。

看来要清理文件来释放空间,还是用>或/usr/lib/acct/nulladm命令稳妥一些,特别是那些可能正在被进程使用的trace、log类文件。


Reader's Comments

  1. |

    受益了!是的,还是用>比较好,我经常这么干,而且喜欢这么干!

Leave a Comment