I've the next script running to backup my apache logs

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

That is scheduled via cron. So each evening the logs get supported and purged. However, the following morning I usually get files with strange figures following the date

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

[me@computer oldlogs]#cat access_log072

and I am not able to locate what's leading to it. Any idea?

logrotate is the friend

I'd be checking:

  • the ${dt} variable from inside the cron job (echo "${dt}" | od -xcb >/tmp/qq) and
  • the particular script itself (od -xcb scriptname)

to ascertain if there's strange figures being produced anywhere.

Also, I can not determine your next command. Can there be an access_log072 file there somewhere or was your command cut down in some way?