本文介绍了Apache日志旋转脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下脚本运行备份我的Apache日志

I have the following script running to backup my apache logs

#!/bin/sh
dt=`date +%m%d%Y`
cp /var/log/httpd/domainname/www/error_log /var/log/httpd/domainname/www/oldlogs/error_log$dt
cat /dev/null > /var/log/httpd/domainname/www/error_log
cp /var/log/httpd/domainname/www/access_log /var/log/httpd/domainname/www/oldlogs/access_log$dt
cat /dev/null > /var/log/httpd/domainname/www/access_log

这是通过cron计划。所以每天晚上日志得到备份和清空。然而,第二天早上我总是得到怪异字符的文件之日起

Which is scheduled via cron. So each night the logs get backed up and emptied. However, the next morning I always get files with weird characters after the date

[me@computer oldlogs]# ls
access_log07202009??  access_log07212009??  error_log07202009??  error_log07212009??

[me@computer oldlogs]#cat access_log072
access_log07202009^M^Maccess_log07212009^M^M

和我找不出是什么原因造成的。任何想法?

and I'm unable to find what is causing it. Any idea?

推荐答案

是你的朋友

这篇关于Apache日志旋转脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 21:58