日志切割脚本不会自动切割日志
因为网站还没有完全搞好,所以写了ROBOTS屏蔽所有蜘蛛:User-agent: *
Disallow: /
可是发现日志切割脚本不会自动切割日志了。
这跟ROBOTS限制有关系吗?
是阿里云的LINUX主机
使用命令:/etc/init.d/crond status
结果提示:crond (pid1749) is running...
[ 本帖最后由 !@#123 于 2013-8-11 15:31 编辑 ] 安装好lnmp后必须设置才行,安装好日志不会自动切割
https://www.vpser.net/manage/cut-nginx-log-files.html
那只是针对rebot的,只要有访问就有日志 军哥,可能是我没有表达清楚。
安装好LNMP后,我已经配置好了日志切割计划任务的。
就是有时会出现无法切割日志,我设置了7天自动删除所有日志,好像是自动删除了7天的日志后自动切割脚本就会停止了。
下面是我的计划任务
crontab -l
00 00 * * * /bin/bash /root/lnmp1.0-full/cut_nginx_logs.sh
00 00 * * 7 /bin/bash /root/lnmp1.0-full/clear_logs.sh
下面是我修改过的日志切割脚本,请军哥看一下是不是因为修改错误造成不会自动切割的。
#!/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 nginx log files you want to cut
log_files_name=(xunwuwang.com)
#set the path to nginx.
nginx_sbin="/usr/local/nginx/sbin/nginx"
#Set how long you want to save
save_days=7
############################################
#Please do not modify the following script #
############################################
mkdir -p $log_files_dir
log_files_num=${#log_files_name[@]}
#cut nginx log files
for((i=0;i<$log_files_num;i++));do
mv ${log_files_path}${log_files_name}.log ${log_files_dir}/${log_files_name}_$(date -d "yesterday" +"%Y%m%d").log
done
#delete 7 days ago nginx log files
find $log_files_path -mtime +$save_days -exec rm -rf {} \;
$nginx_sbin -s reload
[ 本帖最后由 !@#123 于 2013-8-11 20:53 编辑 ] 上面没错误
页:
[1]