Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Script not executing properly

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
aigini82
Posts: 1
Joined: 2017-09-10 09:32

Script not executing properly

#1 Post by aigini82 »

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



lostfarmer
Posts: 19
Joined: 2016-05-07 01:13
Location: Idaho

Re: Script not executing properly

#2 Post by lostfarmer »

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.

Post Reply