I created a script to generate a report (Eximstats Report).
It ran successfully the first time I executed it.
However for 2 times after that it has not been running properly.
Actually the beginning part of the script copies mainlog files within a date range into another directory. This does not work properly anymore. Meaning the mainlog file that is copied over to the destination directory is 0 in size, and not the actual size in /var/log/exim4.
I have already googled for solutions to change the find statement below, but none helps. Please suggest if anything else is wrong with the script.
Please help correct the find statement for this function :
Code: Select all
#!/bin/bash
DAY=$(date +%d)
MONTH=$(date +%b)
YEAR=$(date +%Y)
#eval $(date "+DAY=%d MONTH=%b YEAR=%Y")
BC01="Blast_BC01"
BC07="Blast_BC07"
BC15="Blast_BC15"
DIR1="$MONTH$YEAR"_"$BC01"
DIR2="$MONTH$YEAR"_"$BC07"
DIR3="$MONTH$YEAR"_"$BC15"
eximDATE=$(date +"%d%m%Y")
eximREV01=$(date +"%Y%m%01")
eximREV07=$(date +"%Y%m%07")
eximREV15=$(date +"%Y%m%15")
eximMON=$(date +"%m%Y")
eximBC01=$(date +"01%m%Y")
eximBC07=$(date +"07%m%Y")
eximBC15=$(date +"15%m%Y")
NOW=$(date +"%Y-%m-%d")
TOMORROW=$(date +"%Y-%m-%d" -d "tomorrow")
SECOND=$(date +"%Y-%m-02")
EIGHTH=$(date +"%Y-%m-08")
SIXTEENTH=$(date +"%Y-%m-16")
#cd /var/log/exim4
mkdir -p /var/log/exim4/$YEAR/$DIR2
find /var/log/exim4 -maxdepth 1 -type f -name 'mainlog*' -newermt $EIGHTH ! -newermt $TOMORROW -exec cp {} /var/log/exim4/$YEAR/$DIR2/ \;
cd /var/log/exim4/$YEAR/$DIR2