linux_wiki:tmpwatch

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
linux_wiki:tmpwatch [2015/10/15 22:58]
billdozor [Examples]
linux_wiki:tmpwatch [2015/10/15 23:07]
billdozor
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 =====
Line 76: Line 65:
   * Clean up an application's tmp directory at /opt/app/tmp   * Clean up an application's tmp directory at /opt/app/tmp
   * Check access time (-u), modification time (-m), and change time (-c).    * Check access time (-u), modification time (-m), and change time (-c). 
-  * Delete if any of the three are older than 30 days.+  * Delete if any of the three are older than 30 days (30d).
 <code bash> <code bash>
 tmpwatch -umc 30d /opt/app/tmp tmpwatch -umc 30d /opt/app/tmp
 </code> </code>
 +
 +----
  
 ==== Default /etc/cron.daily/tmpwatch ==== ==== 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.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)