Script not executing properly

If none of the more specific forums is the right place to ask

Script not executing properly

Postby aigini82 » 2017-09-10 09:45

Hi,

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


aigini82
 
Posts: 1
Joined: 2017-09-10 09:32

Re: Script not executing properly

Postby lostfarmer » 2017-09-11 02:07

I do not know script but /var/log/exim4 does require root priv. . So are you running the script as root ? do not see su or sudo in script. If I am way off and that is likely then disregard.
lostfarmer
 
Posts: 13
Joined: 2016-05-07 01:13
Location: Idaho


Return to General Questions

Who is online

Users browsing this forum: No registered users and 6 guests

fashionable