gpt4 book ai didi

Apache 日志轮换脚本

转载 作者:行者123 更新时间:2023-12-04 07:05:33 25 4
gpt4 key购买 nike

我正在运行以下脚本来备份我的 apache 日志

#!/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 安排的。因此,每天晚上,日志都会备份并清空。但是,第二天早上我总是在日期之后收到带有奇怪字符的文件
[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

我无法找到导致它的原因。任何的想法?

最佳答案

logrotate是你的 friend

关于Apache 日志轮换脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1159543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com