Differences
This shows you the differences between two versions of the page.
linux_wiki:tmpwatch [2015/10/15 23:07] billdozor |
linux_wiki:tmpwatch [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Tmpwatch ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | tmpwatch is a utility that recursively removes files that haven' | ||
- | |||
- | It is normally used to clean up directories such as /tmp. | ||
- | |||
- | **Checklist** | ||
- | * Distro: Enterprise Linux 6 | ||
- | |||
- | ---- | ||
- | |||
- | ====== Install ====== | ||
- | |||
- | Tmpwatch does not come installed on a CentOS 6 minimal installation. | ||
- | |||
- | <code bash> | ||
- | yum install tmpwatch | ||
- | </ | ||
- | |||
- | ===== cron.daily ===== | ||
- | |||
- | After installation, | ||
- | |||
- | See examples below for contents and explanation. | ||
- | |||
- | ---- | ||
- | |||
- | ====== Tmpwatch Usage ====== | ||
- | |||
- | Format | ||
- | <code bash> | ||
- | tmpwatch -[options] < | ||
- | </ | ||
- | |||
- | **time** | ||
- | * Threshold for removing files. | ||
- | * Number with optional single character suffix | ||
- | * m = minutes | ||
- | * h = hours (default if not specified) | ||
- | * d = days | ||
- | |||
- | **directories** | ||
- | * One or more directories specified for clean up. (Space separated) | ||
- | |||
- | **Common Options** | ||
- | * -u, --atime => Delete files based on the file's access time. (default setting) | ||
- | * Note: the " | ||
- | * -m, --mtime => Delete files based on the file's modification time. | ||
- | * -c, --ctime => Delete files based on the file's inode change time. For directories, | ||
- | * -a, --all => Remove all file types, not just regular files, symbolic links and directories. | ||
- | * -f, --force => Remove files even if root doesn' | ||
- | * -t, --test => Don't actually remove anything. | ||
- | * -v, --verbose => Print display. | ||
- | * -x => Skip specified path. (if directory, skip all files inside) | ||
- | * -X => Skip paths matching specified pattern. | ||
- | |||
- | ---- | ||
- | |||
- | ===== Examples ===== | ||
- | |||
- | ==== Fictional App in /opt ==== | ||
- | |||
- | * Clean up an application' | ||
- | * 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 / | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ==== Default / | ||
- | |||
- | **First tmpwatch (with all the " | ||
- | * Clean up /tmp | ||
- | * Check access time (-u), modification time (-m), and change time (-c). | ||
- | * Exclude all directories specified after each " | ||
- | * Exclude any directory that matches the pattern after the " | ||
- | * Delete if any of the -umc options are older than 10 days (10d). | ||
- | |||
- | **Second tmpwatch " | ||
- | * 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 / | ||
- | * 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). | ||
- | |||
- | / | ||
- | <code bash> | ||
- | #! /bin/sh | ||
- | flags=-umc | ||
- | / | ||
- | -x / | ||
- | -X '/ | ||
- | / | ||
- | for d in / | ||
- | if [ -d " | ||
- | / | ||
- | fi | ||
- | done | ||
- | </ | ||
- | |||
- | ---- | ||