Linux系統下臨時檔案TMP清理

來源:互聯網
上載者:User
文章目錄
  • Linux系統下臨時檔案TMP清理
Linux系統下臨時檔案TMP清理

系統使用時間長後會產生臨時檔案(/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下三小時以內沒有使用的檔案,並將結果輸出)。
 
  效果:
 
   [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

 

 

----------------

 

tmpwatch在97年就已經被
tmpreaper
取代了,是老得發黴的軟體了,現在都是用tmpreaper

sudo apt-get install tmpreaper
即可

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.