close

最近線上出了個問題,

線上系統回報 - No space left on device

先到該目錄去試試 vi test

出現E212 : Can't open file for writing

df 檢查硬碟空間

發現硬碟空間才使用5X%,

後來才發現是inode用完了,有太多的files和folders,

而inode的大小配置又需要在磁碟格式化時分配,

那麼只能減少磁碟的檔案數了.

步驟如下

1. 找出特定時間內的檔案,先複製到其他磁碟

find /source_path/  -newermt "2000-01-01 00:00:00" ! -newermt "2015-01-01 00:00:00" -type f -print -exec cp --parents --preserve=timestamp "{}" /dest_path/ \;

2. 刪除相同時間內的檔案
find /source_path/  -newermt "2000-01-01 00:00:00" ! -newermt "2015-01-01 00:00:00" -type f -print -exec rm '{}' \;

3. 刪除空目錄 (目錄也是佔inode的)
find /source_path/ -depth -empty -type d -exec rmdir -v {} \;

 

雖然只是禍害另一個磁碟,但只要不是營運使用就好= ="

參考

http://jashliao.pixnet.net/blog/post/161693537-%E6%AF%8F%E5%A4%A9%E4%B8%80%E5%80%8Blinux%E6%8C%87%E4%BB%A4--find%E6%8C%87%E4%BB%A4%E7%9A%84%E5%8F%83%E6%95%B8%E8%A9%B3%E8%A7%A3

http://blog.nutsfactory.net/2010/04/15/find-the-empty-dir/

http://liaozi.blogspot.tw/2015/04/linux.html

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 abcg5 的頭像
    abcg5

    Aaron Yang

    abcg5 發表在 痞客邦 留言(0) 人氣()