1 #!/bin/sh 2 3 # first compress 4 5 # monthly 6 find /var/log/mosshe -mtime +4 -type f \ 7 -name "mosshe_log.[0-9][0-9][0-9][0-9]-[0-9][0-9]" \ 8 -exec bzip2 {} \; 9 10 # weekly 11 find /var/log/mosshe -mtime +4 -type f \ 12 -name "mosshe_log.[0-9][0-9][0-9][0-9]kw[0-9]" \ 13 -exec bzip2 {} \; 14 15 find /var/log/mosshe -mtime +4 -type f \ 16 -name "mosshe_log.[0-9][0-9][0-9][0-9]kw[0-9][0-9]" \ 17 -exec bzip2 {} \; 18 19 #daily 20 find /var/log/mosshe -mtime +4 -type f \ 21 -name "mosshe_log.[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" \ 22 -exec bzip2 {} \; 23 24 25 26 # then delete files older than 2 months 27 28 find /var/log/mosshe -mtime +60 -type f \ 29 -name "mosshe_log.*.bz2" \ 30 -exec rm {} \;