gringomike
Technical User
Hi all,
I need a script to FTP a log file that was created "yesterday". These log files update throughout the day and as soon as midnight passes a new file is created with a new the current date integrated into the file name.
A directory listing returns the following;
access_log.Mar052005.log.Z
access_log.Mar062005.log.Z
access_log.Mar072005.log.Z
access_log.Mar082005.log.Z
access_log.Mar092005.log
Here's what I have so far;
DATE2=`/usr/bin/date +%b%d%Y`
for arg in "access_log.$DATE2.log"
do
DATE=`/usr/bin/date +%d%m%y`
PROFILE=abc
FILE=$arg
NEWFILE=$PROFILE.$DATE
echo "\
open 123.48.75.124
user username password
lcd /log_area
cd /a/b/c
bin
get $FILE
quit
" | ftp -n -i -v
done
cd /nettracker_logs
echo "Renaming log file from $FILE to $NEWFILE"
mv $FILE $NEWFILE
echo "File successfully renamed"
echo "Transfer Complete"
This would work if I ran the script at 23:59 however the only time I have permission to run this script is at 3am. As a result, it only picks up 3 hours worth of data (midnight until 3am)!!
All I have to do is have the script pick up yesterdays file (rather than todays) and unzip it once it has been transfered across.
I'm sure there's an easy way to do this but I can't find the answer using the date command and everything I've tried so far has been unsuccessful.
Help!
I need a script to FTP a log file that was created "yesterday". These log files update throughout the day and as soon as midnight passes a new file is created with a new the current date integrated into the file name.
A directory listing returns the following;
access_log.Mar052005.log.Z
access_log.Mar062005.log.Z
access_log.Mar072005.log.Z
access_log.Mar082005.log.Z
access_log.Mar092005.log
Here's what I have so far;
DATE2=`/usr/bin/date +%b%d%Y`
for arg in "access_log.$DATE2.log"
do
DATE=`/usr/bin/date +%d%m%y`
PROFILE=abc
FILE=$arg
NEWFILE=$PROFILE.$DATE
echo "\
open 123.48.75.124
user username password
lcd /log_area
cd /a/b/c
bin
get $FILE
quit
" | ftp -n -i -v
done
cd /nettracker_logs
echo "Renaming log file from $FILE to $NEWFILE"
mv $FILE $NEWFILE
echo "File successfully renamed"
echo "Transfer Complete"
This would work if I ran the script at 23:59 however the only time I have permission to run this script is at 3am. As a result, it only picks up 3 hours worth of data (midnight until 3am)!!
All I have to do is have the script pick up yesterdays file (rather than todays) and unzip it once it has been transfered across.
I'm sure there's an easy way to do this but I can't find the answer using the date command and everything I've tried so far has been unsuccessful.
Help!