Skip to content

Instantly share code, notes, and snippets.

@yangl
Created September 22, 2015 11:39
Show Gist options
  • Save yangl/273cdea87aa31583b55e to your computer and use it in GitHub Desktop.
Save yangl/273cdea87aa31583b55e to your computer and use it in GitHub Desktop.
定时切割删除日志
#!/bin/sh
log_dir="/data/metricslog"
date_dir=`date +%Y-%m-%d --date='yesterday'`
cd $log_dir
while read line
do
mv ./nginx/$line/metrics.access.log ./nginx/$line/metrics.access.log-$date_dir
done<$log_dir/loglist.txt
/data/soft/nginx/sbin/nginx -s reload
find $log_dir -type f -name "*.log*" -mtime +7 -exec rm -rf {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment