#!/bin/bash # apachedata=$(date +%Y%m%d) time=$(date +%Y%m%d%H –date=‘1 hour ago‘) cd /logs/apache/ tar -zcvf genius_access_log_$time.tar.gz genius_access_log_$time.log mv genius_access_log_$time.tar.gz /logs/apache_visit/ #从今天零时开始7天以外的文件删除 find /logs/apache/ -daystart -type f -mtime +7 -exec rm -f ‘{}‘ ‘;‘