A log / file cleanup and processing commandline tool.
Now Python 3 only. Developed & tested on Linux.
Should also work on Windows and MacOS X but is untested.
springclean.py [options]
Options:
Match options - can choose a file match and time option
-f MATCH, --filematch=MATCH
shell-style wildcard to match logfiles to process
-x MATCHRE, --matchre=MATCHRE
regex to match logfiles to process
-n MTIME_NEWER, --newer=MTIME_NEWER
match files newer than x units (d|h|m|s), eg 3d
-o MTIME_OLDER, --older=MTIME_OLDER
match files older than x units (d|h|m|s), eg 3d
Actions - choose one (defaults to list)
--rm removed matched files
-l, --list list matched files (default action)
-g, --gzip gzip matched files
--mv move matched files to --destdir
--destdir=DESTDIR directory to move files to (with --mv)
Switches - optional
-h, --help show this help message and exit
--dir=DIR directory to match from (default $PWD)
-v, --verbose verbose output
-c, --confirm confirm each individual operation (rm|gzip|mv)
-s, --syslog log successful actions to syslog
List all files that match regex .*.log$ :
springclean -x ".*\.log$"
Remove all files that match mail.log
springclean -f mail.log --rm
Gzip all files older than 7 days with confirmation
springclean --gzip --older 7d --confirm
Move all files newer than 2 weeks to directory /tmp
springclean --newer 2w --mv --destdir /tmp
List all files newer than 3 days in /tmp directory
springclean --dir /tmp --newer 3d --list
Move all files older than 2 hours matching "*.log" to /tmp
springclean --mv -f "*.log" --older 2h --destdir /tmp
Note: unless you have disabled shell wildcard expansion (with set -f) you should quote your wildcards.
What springclean does not do:
- recurse into subdirectories (yet)
- remove directories