find ./ -name "db*" -type f -mmin +$MINS -exec rm {} /;
#find ./ -name "db*" -type f -mtime +$DAYS -exec rm {} /;
exit 0;
定时切割nginx access.log,只保留3天前的记录
放入 /etc/cron.hourly/
#!/bin/bash
# This script run at 00:00
# The Nginx logs path
#logs_path="/usr/local/webserver/nginx/logs/"
logs_path="/data1/logs/"
#How much days backup most
DAYS=3
#Core of script
cd $logs_path
DATE=`date +%Y-%m-%d-%H`
SRC_FILE="access.log"
TAR_FILE="access-$DATE.tar.gz"
tar -czf $TAR_FILE $SRC_FILE
rm -f $SRC_FILE
find ./ -name "access-*" -type f -mtime +$DAYS -exec rm {} /;
kill -USR1 `cat /usr/local/webserver/nginx/nginx.pid`
exit 0;
bitsCN.com