title: Apache Log rotation Script
body: <p>I have the following script running to backup my apache logs</p>
  
  <pre><code>#!/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 &gt; /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 &gt; /var/log/httpd/domainname/www/access_log
  </code></pre>
  
  <p>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</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>and I'm unable to find what is causing it. Any idea?</p>