I would like to know how I should go about rotating files that end with a date stamp. This is the configuration I have to rotate my Apache access files, but it is not working:
The files are created with a date extension like the ones below:
I need to find to rotate them so that I get this:
Since the above is not working, I am working on a script to make it happen, but I am having the following issues:.
This is what I have done so far. I have this script:
for files in $LISTACC $LISTERR
if [[ $files != *.bz2 ]] && [[ -f $files ]]
for files1 in $LISTACC1 $LISTERR1
#if [[ $files1 == *.bz2 ]]
#echo "files ones are: $files1"
$newfilenames=`echo $files1 | sed 's/bz2/1.bz2/g'`
#echo "the new names are $newfilenames"
#mv $files1 $newfilenames
However, for the second for loop, it is not working. These are my log files:
When I run the script, it gives me and error as follows:
[root@scripts willie]# bash newnanme.sh
newnanme.sh: line 38: =access_log.073010-00_00.1.bz2: command not found
newnanme.sh: line 38: =access_log.082810-00_00.1.bz2: command not found
newnanme.sh: line 38: =access_log.083010-00_00.1.bz2: command not found
newnanme.sh: line 38: =access_log.1.bz2: command not found
newnanme.sh: line 38: =error_log.042310-00_00.1.bz2: command not found
newnanme.sh: line 38: =error_log.070910-00_00.1.bz2: command not found
newnanme.sh: line 38: =error_log.080510-00_00.1.bz2: command not found
newnanme.sh: line 38: =error_log.1.bz2: command not found
I want the logs to be renamed to
and so on.
Please someone guide me to fix this error.