linux_wiki:tmpwatch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux_wiki:tmpwatch [2015/10/15 22:43]
billdozor created
linux_wiki:tmpwatch [2019/05/25 23:50] (current)
Line 8: Line 8:
  
 **Checklist** **Checklist**
-  * Distro: Enterprise Linux 6+  * Distro(s): Enterprise Linux 6
  
 ---- ----
Line 22: Line 22:
 ===== cron.daily ===== ===== cron.daily =====
  
-After installation, there will now be a tmpwatch cron script in:+After installation, there will now be a tmpwatch cron script in: /etc/cron.daily/tmpwatch
  
-/etc/cron.daily/tmpwatch +See examples below for contents and explanation.
-<code bash> +
-#! /bin/sh +
-flags=-umc +
-/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \ +
- -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \ +
- -X '/tmp/hsperfdata_*' 10d /tmp +
-/usr/sbin/tmpwatch "$flags" 30d /var/tmp +
-for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do +
-    if [ -d "$d" ]; then +
- /usr/sbin/tmpwatch "$flags" -f 30d "$d" +
-    fi +
-done +
-</code>+
  
 ---- ----
Line 69: Line 56:
   * -x => Skip specified path. (if directory, skip all files inside)   * -x => Skip specified path. (if directory, skip all files inside)
   * -X => Skip paths matching specified pattern.   * -X => Skip paths matching specified pattern.
 +
 +----
  
 ===== Examples ===== ===== Examples =====
  
-Section 2sub-content.+==== Fictional App in /opt ==== 
 + 
 +  * Clean up an application's tmp directory at /opt/app/tmp 
 +  * Check access time (-u)modification time (-m), and change time (-c) 
 +  * Delete if any of the three are older than 30 days (30d). 
 +<code bash> 
 +tmpwatch -umc 30d /opt/app/tmp 
 +</code> 
 + 
 +---- 
 + 
 +==== Default /etc/cron.daily/tmpwatch ==== 
 + 
 +**First tmpwatch (with all the "-x")** 
 +  * Clean up /tmp 
 +  * Check access time (-u), modification time (-m), and change time (-c). 
 +  * Exclude all directories specified after each "-x" 
 +  * Exclude any directory that matches the pattern after the "-X" 
 +  * Delete if any of the -umc options are older than 10 days (10d). 
 + 
 +**Second tmpwatch "$flags" 30d /var/tmp** 
 +  * Clean up /var/tmp 
 +  * Check access time (-u), modification time (-m), and change time (-c). 
 +  * Delete if any of the -umc options are older than 30 days (30d). 
 + 
 +**Third /usr/sbin/tmpwatch "$flags" -f 30d "$d"** 
 +  * Clean up each directory ($d) in the for loop pattern. 
 +  * Check access time (-u), modification time (-m), and change time (-c). 
 +  * Force deletion (-f) 
 +  * Delete if any of the -umc options are older than 30 days (30d). 
 + 
 +/etc/cron.daily/tmpwatch 
 +<code bash> 
 +#! /bin/sh 
 +flags=-umc 
 +/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \ 
 + -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \ 
 + -X '/tmp/hsperfdata_*' 10d /tmp 
 +/usr/sbin/tmpwatch "$flags" 30d /var/tmp 
 +for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do 
 +    if [ -d "$d" ]; then 
 + /usr/sbin/tmpwatch "$flags" -f 30d "$d" 
 +    fi 
 +done 
 +</code>
  
 ---- ----
  
  • linux_wiki/tmpwatch.1444963423.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)