linux之tmpwatch命令

來源:互聯網
上載者:User

標籤:

系統使用時間長後會產生臨時檔案(/tmp下),需要清理。但清理的時候不推薦使用rm -rf。這樣有時會引起程式的僵死。

tmpwatch的說明:

[[email protected] ~]# tmpwatchtmpwatch 2.9.16 - (C) 1997-2009 Red Hat, Inc. All rights reserved.This program may be freely redistributed under the terms of theGNU 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_25593dd8b8bed7870df27162b7be5125removing file /tmp/.ICE-unix/sess_a0179d8a297cfd463b5fac7fd6efc97cremoving file /tmp/.ICE-unix/sess_6fb81c6b2234f6adc3fbe9557ac713d6removing file /tmp/.ICE-unix/sess_6aadb21e0efe642e5c4a71f01e215865removing file /tmp/.ICE-unix/sess_99d178821da1c33f5eae0511e672d30cremoving file /tmp/.ICE-unix/sess_433ca52b1c31b9af65d373d75890ceb7removing file /tmp/.ICE-unix/sess_d4f9c6129bf2bb1d81398500ac5a569eremoving file /tmp/.ICE-unix/sess_7d29f5d3c259f1c6c4bedde9f975f6c9removing file /tmp/.ICE-unix/sess_54c5baab9a157b9c613a38852ebf4397removing file /tmp/.ICE-unix/sess_b2ac522cec3561e8d4c8172cdd408ae3removing file /tmp/.ICE-unix/sess_9f2de1c14f60637324317cf515b99952removing file /tmp/.ICE-unix/sess_db09a1bc04b65b08b35ab5a4787b7eferemoving file /tmp/.ICE-unix/sess_599d3263d6bf162b136784fd682d30ccremoving file /tmp/.ICE-unix/sess_2b49e884ad6f741a843c3fa237bf74f2removing file /tmp/.ICE-unix/sess_e5d55bfa44d8962eba04f4e57d8d53f5removing file /tmp/.ICE-unix/sess_8f493b6e85505169cafc33c8a3193493removing file /tmp/.ICE-unix/sess_108b66b39811a985177b2ef1e4bf8d30removing file /tmp/.ICE-unix/sess_69327aaafc1dedc20e4b8bea4115850cremoving file /tmp/.ICE-unix/sess_50626890a77806861675b031e1f8cfa1removing file /tmp/.ICE-unix/sess_03e670ba79e12a86190645ce52bf3c43removing file /tmp/.ICE-unix/sess_fb0db280a802e7b824d4d984557eb566removing file /tmp/.ICE-unix/sess_a0f732bc28ed00e5bce03ca52ff9a143removing file /tmp/.ICE-unix/sess_d5490bc5f57098d4ac13e160c9fc179dremoving file /tmp/.ICE-unix/sess_d042ffcea88c97681b9acf59e1b36965removing file /tmp/.ICE-unix/sess_7834543a2e401f1efff4943eae4da14b

 

linux之tmpwatch命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.