A-A+
Lnmp下Nginx日志自动切割脚本
该脚本会自动切割/home/wwwlogs/目录下所有的log文件
#!/bin/bash #自动版日志切割 无需设置 #function:cut nginx log files for lnmp v0.5 and v0.6 #author: http://lnmp.org #set the path to nginx log files log_files_path="/home/wwwlogs/" log_files_dir=${log_files_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m") #set the path to nginx. nginx_sbin="/usr/local/nginx/sbin/nginx" #Set how long you want to save save_days=30 ############################################ #Please do not modify the following script # ############################################ mkdir -p $log_files_dir cd $log_files_path #cut nginx log files for d in `ls -f *.log`;do mv ${log_files_path}${d} ${log_files_dir}/$(date -d "yesterday" +"%Y%m%d")_$d done #delete 30 days ago nginx log files find $log_files_path -mtime +$save_days -exec rm -rf {} \; $nginx_sbin -s reload
Warning: A non-numeric value encountered in /data/wwwroot/lxy.me/wp-content/themes/Ality/inc/functions/comment-template.php on line 16
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /data/wwwroot/lxy.me/wp-content/themes/Ality/functions.php on line 249
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /data/wwwroot/lxy.me/wp-content/themes/Ality/functions.php on line 249
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /data/wwwroot/lxy.me/wp-content/themes/Ality/functions.php on line 249