Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1034
  • Last Modified:

Archiving by month shell script

Hi Guys,

I have the following  shell script that tars up files older than 30 days and moves the files in to an archive directory, I want to modify the script so instead of taring and archiving the last 30 days of data archives tar up only the previos second month for example: on feb 5th 2010  the script has to archive the month of December 2009 on to directory name december09, here's what I got:

#!/bin/ksh
#
# SCRIPT NAME: ap_arc.ksh
#
# PURPOSE: The purpose of this script is to move files older than 30 days in to an archive directory.
#
# REQUIREMENTS: The file(s) have to be 30 days or older to be tar up and archived
# VARIABLES Defined on /home/fsrconnect/autosys/common/profile_bourne
# Find files older than 30 days and move them to the archive directory
#
# EXIT CODES:    0 ==> NORMAL EXECUTION
#               39 ==> NO FILES TO ARCHIVE
#               40 ==> TAR AND COMPRESSION OF THE AP FILES NOT EXECUTED
#               41 ==> NOT ABLE TO REMOVED FILES FROM TAR_AP DIRECTORY
#               42 ==> FILE `date "+%y%m%d".AP.tgz` IS MISSING ON THE CURRENT MONTH DIRECTORY


# SORT PROFILE FILE

. /home/fsrconnect/autosys/common/profile_bourne

# Month Array

month[0]="none"
month[01]="January"
month[02]="February"
month[03]="March"
month[04]="April"
month[05]="May"
month[06]="June"
month[07]="July"
month[08]="August"
month[09]="September"
month[10]="October"
month[11]="November"
month[12]="December"

# AP

cd $AP_ARC
find $AP_ARC -mtime +30 -exec mv -f {} $TAR_AP \;
cd $TAR_AP
ls -l $TAR_AP > /dev/null 2>&1
if [[ $? != 0 ]] ; then
        echo " THERE ARE NO FILES OLDER THAN 30 DAYS TO ARCHIVE AT THE MOMENT. "

cd $AP_ARC
find $AP_ARC -mtime +30 -exec mv -f {} $TAR_AP \;
cd $TAR_AP
ls -l $TAR_AP > /dev/null 2>&1
if [[ $? != 0 ]] ; then
        echo " THERE ARE NO FILES OLDER THAN 30 DAYS TO ARCHIVE AT THE MOMENT. "
        exit 39
fi

tar cvf - *.* | gzip -c > `date "+%y%m%d".AP.tgz`
ls -l `date "+%y%m%d".AP.tgz` > /dev/null 2>&1
if [[ $? != 0 ]] ; then

        echo " ERROR: TAR AND COMPRESSION OF THE AP FILES NOT EXECUTED. "
        exit 40
fi

rm -f $(ls * | grep -v *.tgz)
if [[ $? != 0 ]] ; then
        echo " ERROR: NOT ABLE TO REMOVED FILES FROM TAR_AP DIRECTORY. "
        exit 41
fi

a=`date "+%m"`
mv *.tgz $TAR_AP/${month[$a]}
if [[ $? != 0 ]] ; then

        echo " ERROR: FILE `date "+%y%m%d".AP.tgz` IS MISSING ON THE CURRENT MONTH DIRECTORY "
        exit 42

fi


Thanks for your help.!!!

0
HIONSPD
Asked:
HIONSPD
  • 21
  • 14
  • 3
1 Solution
 
MikeOM_DBACommented:
Try this:
 

# ...Blah, Blah, Blah...

# SORT PROFILE FILE
. /home/fsrconnect/autosys/common/profile_bourne

# Month Array
month=("none" "January" "February" "March" "April" "May" "June" 
       "July" "August" "September" "October" "November" "December")

dt=(`date +%Y\ %m\ %d`)
Y=${dt[0]}; M=${dt[1]}; D=${dt[2]}
echo "%+ Today's date: $M/$D/$Y"
(( M = M - 2 ))
if [ $M -lt 1 ]; then
  (( Y = Y - 1 )); (( M = M + 12 ))
fi  
filedt=$(printf "%s%0.2d%0.2d" $Y $M $D;)
rm arc*.tmp
touch -t ${filedt}0000 arc$$.tmp
echo "%+ Archive date: $M/$D/$Y; ${month[$M]}; $filedt"

## AP

cd $AP_ARC
find . ! -newer arc$$.tmp 
if [[ $? != 0 ]] ; then
  echo "!ERROR $?: THERE ARE NO FILES OLDER THAN $M/$D/$Y TO ARCHIVE AT THE MOMENT. "
  exit 39
fi
tgzFile="${month[$M]}-${dt[0]}${dt[1]}${dt[2]}.AP.tgz"
find . ! -newer arc$$.tmp |xargs -I! tar cvf - ! | gzip -c > ${TAR_AP}/$tgzFile
if [[ $? != 0 ]] ; then
  echo "!ERROR $?: TAR AND COMPRESSION OF THE AP FILES NOT EXECUTED. "
  exit 40
fi

find . ! -newer arc$$.tmp -exec rm {} \;
if [[ $? != 0 ]] ; then
  echo "!ERROR $?: NOT ABLE TO REMOVE FILES FROM AR DIRECTORY. "
  exit 41
fi

exit 0

Open in new window

0
 
MikeOM_DBACommented:
Fixed some typo's:
 

# ...Blah, Blah, Blah...

# SORT PROFILE FILE
. /home/fsrconnect/autosys/common/profile_bourne

# Month Array + Misc variables:
month=("none" "January" "February" "March" "April" "May" "June" 
       "July" "August" "September" "October" "November" "December")
dt=(`date +%Y\ %m\ %d`)
Y=${dt[0]}; M=${dt[1]}; D=${dt[2]}
echo "%+ Today's date: $M/$D/$Y"
(( M = M - 2 ))
if [ $M -lt 1 ]; then
  (( Y = Y - 1 )); (( M = M + 12 ))
fi  
filedt=$(printf "%s%0.2d%0.2d" $Y $M $D;)
echo "%+ Archive date: $M/$D/$Y"
rm arc*.tmp 2>/dev/null
touch -t ${filedt}0000 arc$$.tmp
TAR_DIR="${TAR_AP}/${month[$M]}${Y#??}"
[ ! -d $TAR_DIR ] && mkdir -p $TAR_DIR
tgzFile="${dt[0]}${dt[1]}${dt[2]}.AP.tgz"
echo "%+ TAR Dir/File: $TAR_DIR/$tgzFile" 

## AP

cd $AP_ARC
find . ! -newer arc$$.tmp >/dev/null 2>&1
if [[ $? != 0 ]] ; then
  echo "!ERROR $?: THERE ARE NO FILES OLDER THAN $M/$D/$Y TO ARCHIVE AT THE MOMENT. "
  exit 39
fi
find . ! -newer arc$$.tmp |xargs -I! tar cvf - ! | gzip -c > ${TAR_DIR}/$tgzFile
if [[ $? != 0 ]] ; then
  echo "!ERROR $?: TAR AND COMPRESSION OF THE AP FILES NOT EXECUTED. "
  exit 40
fi
find . ! -newer arc$$.tmp -exec rm {} \;
if [[ $? != 0 ]] ; then
  echo "!ERROR $?: NOT ABLE TO REMOVE FILES FROM AR DIRECTORY. "
  exit 41
fi

exit 0

Open in new window

0
 
HIONSPDAuthor Commented:
Hey Mike,

I'm reviewing and testing your sujestion...

Thanks.

 
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
TintinCommented:
With GNU date, your code would be hugely simplified.  What Unix/Linux platform are you on and do you have or can you install GNU date?
0
 
MikeOM_DBACommented:
Ooops, fixed a bug in the tar file.
 

# ...Blah, Blah, Blah...

# SORT PROFILE FILE
. /home/fsrconnect/autosys/common/profile_bourne

# Month Array
month=("none" "January" "February" "March" "April" "May" "June" 
      "July" "August" "September" "October" "November" "December")

dt=(`date +%Y\ %m\ %d`)
Y=${dt[0]}; M=${dt[1]}; D=${dt[2]}
echo "%+ Today's date: $M/$D/$Y"
(( M = M - 2 ))
if [ $M -lt 1 ]; then
  (( Y = Y - 1 )); (( M = M + 12 ))
fi  
filedt=$(printf "%s%0.2d%0.2d" $Y $M $D;)
echo "%+ Archive date: $M/$D/$Y"
touch -t ${filedt}0001 arc$$.tmp
TAR_DIR="${TAR_AP}/${month[$M]}${Y#??}"
fileList=$AP_ARC/tarFiles.tmp
[ ! -d $TAR_DIR ] && mkdir -p $TAR_DIR
tgzFile="${dt[0]}${dt[1]}${dt[2]}.AP.tgz"
echo "%+ TAR Dir/File: $TAR_DIR/$tgzFile" 

## AP

cd $AP_ARC
find . ! -newer arc$$.tmp >/dev/null 2>&1
if [[ $? != 0 ]] ; then
  echo "!ERROR 39: THERE ARE NO FILES OLDER THAN $M/$D/$Y TO ARCHIVE AT THE MOMENT. "
  exit 39
fi

find . ! -newer arc$$.tmp -a ! -name '*.tmp' >$fileList.tmp
tar cvf - -T $fileList.tmp | gzip -c > ${TAR_DIR}/$tgzFile
if [[ $? != 0 ]] ; then
  echo "!ERROR 40: TAR AND COMPRESSION OF THE AP FILES NOT EXECUTED. "
  exit 40
fi
exit 0
find . ! -newer arc$$.tmp -exec rm {} \;
if [[ $? != 0 ]] ; then
  echo "!ERROR 41: NOT ABLE TO REMOVE FILES FROM AR DIRECTORY. "
  exit 41
fi

rm *.tmp
exit 0

Open in new window

0
 
HIONSPDAuthor Commented:
Solaris 10 ...unfortunatelly I canot install that tool
0
 
HIONSPDAuthor Commented:
Mike,

The month array pops a syn-err :
# Month Array
month=("none" "January" "February" "March" "April" "May" "June"
      "July" "August" "September" "October" "November" "December")
ksh: syntax error: `(' unexpected
0
 
HIONSPDAuthor Commented:
Mike,
+ ((  M = M - 2  ))
mth.ksh[11]:  M = M - 2 : bad number

Question: is your script for .ksh ...?

Thanks
0
 
MikeOM_DBACommented:
No my script is for bash, but try this for solaris:
 

# -- etc --
# Month Array 
set -A month "none" "January" "February" "March" "April" "May" "June" \  
      "July" "August" "September" "October" "November" "December" 
 
set -A dt `date +%Y\ %m\ %d`
# -- etc --

Open in new window

0
 
HIONSPDAuthor Commented:
Mike,

I do appreciate your effort on your script but Im encountering lots of bugs all along the script when trying to translate it from bash to .ksh

0
 
MikeOM_DBACommented:
What bugs? I don't have solaris available now, but I can help you debug it.
 
0
 
HIONSPDAuthor Commented:
Cool.....I appreciate that&!!!!

I made the following changes:
# Month Array
set -A month "none" "January" "February" "March" "April" "May" "June" \
"July" "August" "September" "October" "November" "December"

dt=`date +%Y\ %m\ %d`
Y=${dt[0]}; M=${dt[1]}; D=${dt[2]}
echo "Today's date: $M$D$Y"
<<<<Up to this point seems to be working fine>>>>>>

**** BUG AREA****
(( M = M - 2 ))
BUG---> ksh: M = M - 2 : bad number

*******Condition bug*********
if [ $M -lt 1 ]; then
(( Y = Y - 1 )); (( M = M + 12 ))
fi
BUG---> ksh: -: unknown test operator
******************************
filedt=$(printf "%s%0.2d%0.2d" $Y $M $D;)
BUG---> printf: - expected numeric value


Lets fix these ones first and we go from there...
Thanks



 
0
 
MikeOM_DBACommented:

Ok, lets try this first:

typeset -i Y=${dt[0]}
typeset -i M=${dt[1]}
typeset -i D=${dt[2]}

if [  M -lt 1 ]; then

It should fix the "numeric" value errors.
 
 
0
 
MikeOM_DBACommented:
I installed ksh on my Ubuntu and got it working now:
 

#!/usr/bin/ksh
# ...Blah, Blah, Blah...

# SORT PROFILE FILE
. /home/fsrconnect/autosys/common/profile_bourne

##---------------------------------------------
## Month Array + Misc variables
set -A month "none" "January" "February" "March" "April" "May" "June" \
           "July" "August" "September" "October" "November" "December"
set -A dt `date +%Y\ %m\ %d`

typeset -i Y=${dt[0]}
typeset -i M=${dt[1]}
typeset -i D=${dt[2]}
today=`date +%Y%m%d`
echo "%+ Today's date: $M/$D/$Y"
(( M = M - 1 ))
if [ M -lt 1 ]
then
  (( Y = Y - 1 )); (( M = M + 12 ))
fi
fileDate=`printf "%s%02d%02d" $Y $M 1`
(( M = M - 1 ))
if [ M -lt 1 ]
then
  (( Y = Y - 1 )); (( M = M + 12 ))
fi
arcDate=`printf "%s%02d%02d" $Y $M $D`
echo "%+ Archive date < $fileDate"
rm ${TAR_AP}/*.tmp
touch -t ${fileDate}0001 ${TAR_AP}/arc$$.tmp
TAR_DIR="${TAR_AP}/${month[$M]}${Y#??}"
fileList=${TAR_AP}/tarFiles.tmp
[ ! -d $TAR_DIR ] && mkdir -p $TAR_DIR
tgzFile="${dt[0]}${dt[1]}${dt[2]}.AP.tgz"
echo "%+ TAR Dir/File: $TAR_DIR/$tgzFile" 

##---------------------------------------------
## AP

cd $AP_ARC
find . ! -newer ${TAR_AP}/arc$$.tmp #>/dev/null 2>&1
if [[ $? -ne 0 ]] ; then
  echo "!ERROR $?: THERE ARE NO FILES OLDER THAN $M/$D/$Y TO ARCHIVE AT THE MOMENT. "
  exit 39
fi

find . ! -newer ${TAR_AP}/arc$$.tmp -a ! -name '*.tmp' >$fileList
tar cvf - -T $fileList | gzip -c > ${TAR_DIR}/$tgzFile
if [[ $? -ne 0 ]] ; then
  echo "!ERROR $?: TAR AND COMPRESSION OF THE AP FILES NOT EXECUTED. "
  exit 40
fi
exit 0
find . ! -newer ${TAR_AP}/arc$$.tmp #-exec rm {} \;
if [[ $? -ne 0 ]] ; then
  echo "!ERROR $?: NOT ABLE TO REMOVE FILES FROM AR DIRECTORY. "
  exit 41
fi

rm ${TAR_AP}/*.tmp
exit 0

Open in new window

0
 
HIONSPDAuthor Commented:
Sorry Mike I took a couple days off I'll review in am

Thanks again..!!!
0
 
HIONSPDAuthor Commented:
Mike.

Thanks again for your help I just tested the script and works great..!!!

:   )
0
 
HIONSPDAuthor Commented:
Great job Mike..!!!!
0
 
MikeOM_DBACommented:
I removed an unecesary step:
 

#!/usr/bin/ksh 
# ...Blah, Blah, Blah... 
 
# SORT PROFILE FILE 
. /home/fsrconnect/autosys/common/profile_bourne 
 
##--------------------------------------------- 
## Month Array + Misc variables 
set -A month "none" "January" "February" "March" "April" "May" "June" \ 
           "July" "August" "September" "October" "November" "December" 
set -A dt `date +%Y\ %m\ %d` 
 
typeset -i Y=${dt[0]} 
typeset -i M=${dt[1]} 
typeset -i D=${dt[2]} 
today=`date +%Y%m%d` 
echo "%+ Today's date: $M/$D/$Y" 
(( M = M - 1 )) 
if [ M -lt 1 ] 
then 
  (( Y = Y - 1 )); (( M = M + 12 )) 
fi 
fileDate=`printf "%s%02d%02d" $Y $M 1` 
(( M = M - 1 )) 
if [ M -lt 1 ] 
then 
  (( Y = Y - 1 )); (( M = M + 12 )) 
fi 
arcDate=`printf "%s%02d%02d" $Y $M $D` 
echo "%+ Archive date < $fileDate" 
rm ${TAR_AP}/*.tmp #*/
touch -t ${fileDate}0001 ${TAR_AP}/arc$$.tmp 
TAR_DIR="${TAR_AP}/${month[$M]}${Y#??}" 
fileList=${TAR_AP}/tarFiles.tmp 
[ ! -d $TAR_DIR ] && mkdir -p $TAR_DIR 
tgzFile="${dt[0]}${dt[1]}${dt[2]}.AP.tgz" 
echo "%+ TAR Dir/File: $TAR_DIR/$tgzFile"  
 
##--------------------------------------------- 
## AP 
 
cd $AP_ARC 

find . ! -newer ${TAR_AP}/arc$$.tmp -a ! -name '*.tmp' >$fileList 2>&1 
if [[ $? -ne 0 ]] ; then 
  echo "!ERROR $?: THERE ARE NO FILES OLDER THAN $M/$D/$Y TO ARCHIVE AT THE MOMENT. " 
  exit 39 
fi 
tar cvf - -T $fileList | gzip -c > ${TAR_DIR}/$tgzFile 
if [[ $? -ne 0 ]] ; then 
  echo "!ERROR $?: TAR AND COMPRESSION OF THE AP FILES NOT EXECUTED. " 
  exit 40 
fi 

find . ! -newer ${TAR_AP}/arc$$.tmp -exec rm {} \; 
if [[ $? -ne 0 ]] ; then 
  echo "!ERROR $?: NOT ABLE TO REMOVE FILES FROM AP DIRECTORY. " 
  exit 41 
fi 
 
rm ${TAR_AP}/*.tmp 
exit 0

Open in new window

0
 
HIONSPDAuthor Commented:
Mike

what command would you use to gunzip and untar the file
I try gunzip < 20100115.AP.tgz | tar xvf - but I got a block size error message
0
 
TintinCommented:
You need

gzip -dc 20100115.AP.tgz | tar xvf -
0
 
MikeOM_DBACommented:
Try:
gunzip -c  20100115.AP.tgz  | tar xvf -
 
0
 
HIONSPDAuthor Commented:
I try gunzip -c  20100115.AP.tgz  | tar xvf -  and try it again with a new created file but I got same block size error message ...!!!
0
 
TintinCommented:
-c flag is for compressing.

Should be

gzip -dc 20100115.AP.tgz | tar xvf -

or

gunzip -d 20100115.AP.tgz | tar xvf -
0
 
HIONSPDAuthor Commented:
Thanks that help...
0
 
HIONSPDAuthor Commented:
Mike..
 
this message pops on the log file:

+ July August September October November December
ap_arc.ksh[10]: July:  not found
0
 
HIONSPDAuthor Commented:
Also when I gunzip the file there's no data on it:

gunzip < 20100119.AP.tgz | tar xvf -
x -T, 5120 bytes, 10 tape blocks
x /nfsshare/Interface/AP/Outbound/Archive/Tar/tarFiles.tmp, 3223 bytes, 7 tape blocks

any ideas...?
0
 
MikeOM_DBACommented:

1) The --[10]July not found error message: a) put all month values inside quotes and b) you may need a back-slash (\) on the preceeding line.
2)  gunzip -c  20100115.AP.tgz  | tar xvf -  is the correct format (man gunzip). On some *nix flavours the gunzip utility expects the file to have a '.gz' suffix, therefore try naming the file as: 20100115.AP.tar.gz and invoke without the suffix:
gunzip -c  20100115.AP.tar  | tar xvf -

0
 
HIONSPDAuthor Commented:
Mike,
Here's the output of the script :
 
.  /home/fsrconnect/autosys/common/profile_bourne
+ SCRIPTDIR=/home/fsrconnect/scripts
+ export SCRIPTS
+ PERLSCRIPTS=/nfsshare/autosys/perl
+ export PERLSCRIPTS
+ STDOUT=/nfsshare/autosys/qa1/out
+ export STDOUT
+ STDERR=/nfsshare/autosys/qa1/err
+ export STDERR
+ STDARC=/nfsshare/autosys/qa1/archive
+ export STDARC
+ GL_OUT=/nfsshare/Interface/GL/Outbound
+ export GL_OUT
+ GL_OUT_DAS=/nfsshare/Interface/GL/Outbound/DAS/Output
+ export GL_OUT_DAS
+ AP_OUT_VNDR=/nfsshare/Interface/AP/Outbound/VENDOR_SYNDICATION
+ export AP_OUT_VNDR
+ AP_OUT_DRAFT5=/nfsshare/Interface/AP/Outbound/Draft5/Outbound
+ export AP_OUT_DRAFT5
+ AP_OUT_TSYS=/nfsshare/Interface/AP/Outbound/Tsys/Outbound
+ export AP_OUT_TSYS
+ AP_OUT=/nfsshare/Interface/AP/Outbound
+ export AP_OUT
+ FA_OUT=/nfsshare/Interface/FA/Outbound
+ export FA_OUT
+ OTH_OUT=/nfsshare/Interface/Ohters/Outbound
+ export OTH_OUT
+ SCM_OUT=/nfsshare/Interface/SCM/Outbound
+ export SCM_OUT
+ PAY_OUT=/nfsshare/Others/AP/Outbound/Output
+ export PAY_OUT
+ RDRQA_OUT=/rdr-ds1/apphome/ctrdr/qa/data
+ export RDRQA_OUT
+ GL_OUT_205=/nfsshare/Interface/GL/Outbound/INSIGHT_GLF205A/Output
+ export GL_OUT_205
+ GL_OUT_260=/nfsshare/Interface/GL/Outbound/INSIGHT_GLF260/Output
+ export GL_OUT_260
+ CSDB_OUT=/nfsshare/Interface/Security/Outbound/CSDB/Output
+ export CSDB_OUT
+ STGAMER=/nfsshare/Interface/Stage/americas
+ export STGAMER
+ STGEMEA=/nfsshare/Interface/Stage/emea
+ export STGEMEA
+ STGASIA=/nfsshare/Interface/Stage/asia
+ export STGASIA
+ STGDOM=/nfsshare/Interface/Stage/domestic
+ export STGDOM
+ STGCUTGL=/nfsshare/Interface/Stage/CUTOVER_1b/GL
+ export STGCUTGL
+ STGCUTBI=/nfsshare/Interface/Stage/CUTOVER_1b/BI
+ export STGCUTBI
+ CONV_IN=/nfsshare/Conversion/GL/Inbound/STANDARD_INTERFACE/Input
+ export CONV_IN
+ GL_IN=/nfsshare/Interface/GL/Inbound
+ export GL_IN
+ AP_IN=/nfsshare/Interface/AP/Inbound
+ export AP_IN
+ FA_IN=/nfsshare/Interface/FA/Inbound
+ export FA_IN
+ OTH_IN=/nfsshare/Interafce/Others/Inbound
+ export OTH_IN
+ SCM_IN=/nfsshare/Interface/SCM/Inbound
+ export SCM_IN
+ FX_IN=/nfsshare/Interface/GL/Inbound/FX_RATES/Input
+ export FX_IN
+ INS_IN=/nfsshare/autosys/qa1/transfer/in
+ export INS_IN
+ GL_TXN_IN=/nfsshare/Interface/GL/Inbound/STANDARD_INTERFACE/Input
+ export GL_TXN_IN
+ GBS_TXN_IN=/nfsshare/Interface/GL/Inbound/GBS_STANDARD_INTERFACE/Input
+ export GBS_TXN_IN
+ AP_CONCUR_IN=/nfsshare/Interface/AP/Inbound/Concur/Input
+ export AP_CONCUR_IN
+ AFI_IN=/nfsshare/afi/input/init
+ export AFI_IN
+ AFI_INBD=/nfsshare/Interface/AFI/Inbound/
+ export AFI_INBD
+ AFI_HOLD=/nfsshare/Interface/AFI/Holding/QA
+ export AFI_HOLD
+ AFI_PHOLD=/nfsshare/Interface/AFI/Holding/Prod
+ export AFI_PHOLD
+ GL_ARC=/nfsshare/Interface/GL/Outbound/Archive
+ export GL_ARC
+ GL_ARC_IN=/nfsshare/Interface/GL/Inbound/Archive
+ export GL_ARC_IN
+ GL_DAS_ARC=/nfsshare/Interface/GL/Outbound/DAS/Archive
+ export GL_DAS_ARC
+ TAR_GL=/nfsshare/Interface/GL/Outbound/Archive/Tar
+ export TAR_GL
+ TAR_GL_IN=/nfsshare/Interface/GL/Inbound/Archive/Tar
+ export TAR_GL_IN
+ AP_ARC=/nfsshare/Interface/AP/Outbound/Archive
+ export AP_ARC
+ AP_ARC_IN=/nfsshare/Interface/AP/Inbound/Archive
+ export AP_ARC_IN
+ TAR_AP=/nfsshare/Interface/AP/Outbound/Archive/Tar
+ export TAR_AP
+ TAR_AP_IN=/nfsshare/Interface/AP/Inbound/Archive/Tar
+ export TAR_AP_IN
+ FA_ARC=/nfsshare/Interface/FA/Outbound/Archive
+ export FA_ARC
+ FA_ARC_IN=/nfsshare/Interface/FA/Inbound/Archive
+ export FA_ARC_IN
+ TAR_FA=/nfsshare/Interface/FA/Outbound/Archive/Tar
+ export TAR_FA
+ TAR_FA_IN=/nfsshare/Interface/FA/Inbound/Archive/Tar
+ export TAR_FA_IN
+ OTH_ARC=/nfsshare/Interface/Others/Outbound/Archive
+ export OTH_ARC
+ OTH_ARC_IN=/nfsshare/Interface/Others/Inbound/Archive
+ export OTH_ARC
+ TAR_OTH=/nfsshare/Interface/Others/Outbound/Archive/Tar
+ export TAR_OTH
+ TAR_OTH_IN=/nfsshare/Interface/Others/Inbound/Archive/Tar
+ export TAR_OTH_IN
+ SCM_ARC=/nfsshare/Interface/SCM/Outbound/Archive
+ export SCM_ARC
+ SCM_ARC_IN=/nfsshare/Interface/SCM/Inbound/Archive
+ export SCM_ARC_IN
+ TAR_SCM=/nfsshare/Interface/SCM/Outbound/Archive/Tar
+ export TAR_SCM
+ TAR_SCM_IN=/nfsshare/Interface/SCM/Inbound/Archive/Tar
+ export TAR_SCM_IN
+ INS_ARC=/nfsshare/autosys/qa1/transfer/out
+ export INS_ARC
+ CSDB_ARC=/nfsshare/Interface/Security/Outbound/CSDB/Archive
+ export CSDB_ARC
+ sapdir=/home/fsrconnect/data
+ export sapdir
+ figdevdir=/figdev-ds1/apphome/fig/dev/data/na/stage/
+ export figdevdir
+ figsysdir=/figsys-ds1/apphome/fig/sys/data/na/stage/
+ export figsysdir
+ figqadir=/figqa-ds1/apphome/figqa/qa/data/na/stage/
+ export figqadir
+ rdrdir=/rdr-ds1/apphome/ctrdr/dev/inbound/
+ export rdrdir
+ rdrqadir=/rdr-ds1/apphome/ctrdr/qa/inbound/
+ export rdrqadir
+ mxusbsdly=\\emamxmtst03\\CDDATA\\ZGL_OUT_GBS_MEX_USBS_DAILY\\
+ export mxusbsdly
+ mxuspldly=\\emamxmtst03\\CDDATA\\ZGL_OUT_GBS_MEX_USPL_DAILY\\
+ export mxuspldly
+ mxlocbsdly=\\emamxmtst03\\CDDATA\\ZGL_OUT_GBS_MEX_LOCBS_DAILY\\
+ export mxlocbsdly
+ mxlocpldly=\\emamxmtst03\\CDDATA\\ZGL_OUT_GBS_MEX_LOCPL_DAILY\\
+ export mxlocpldly
+ mxusbsme=\\emamxmtst03\\CDDATA\\ZGL_OUT_GBS_MEX_USBS_MONTHEND\\
+ export mxusbsme
+ mxusplme=\\emamxmtst03\\CDDATA\\ZGL_OUT_GBS_MEX_USPL_MONTHEND\\
+ export mxusplme
+ mxlocbsme=\\emamxmtst03\\CDDATA\\ZGL_OUT_GBS_MEX_LOCBS_MONTHEND\\
+ export mxlocbsme
+ mxlocplme=\\emamxmtst03\\CDDATA\\ZGL_OUT_GBS_MEX_LOCPL_MONTHEND\\
+ export mxlocplme
+ candir=\\CRPTORIISZL\\ConnectDirectSAP$\\
+ export candir
+ candirnew=\\CRPTORIIS09Q\\ConnectDirectSAP$\\
+ export candirnew
+ insdata=/devdata/TINC/data
+ export insdata
+ insdatapost=/devdata/TINC/data_post
+ export insdatapost
+ NDM_BASE=/opt/cdunix
+ export NDM_BASE
+ PATH=.:/opt/autotree/autosys/bin:/opt/autotree/autosys/test/bin:/bin:/usr/bin:/usr/local/bin:/usr/openwin/bin:/usr/bin/X11:/bin:/usr/ucb:/usr/etc:/usr/sbin:/opt/cdunix/ndm/bin:/opt/cdunix/ndm/cfg/va2ztsap012:/home/fsrconnect
+ export PATH
+ NDMAPICFG=/opt/cdunix/ndm/cfg/cliapi/ndmapi.cfg
+ export NDMAPICFG
+ set -A month "none" "January" "February" "March" "April" "May" "June" \
           "July" "August" "September" "October" "November" "December"
+ date +%Y %m %d
+ set -A dt 2010 01 20
+ typeset -i Y=2010
+ typeset -i M=01
+ typeset -i D=20
+ + date +%Y%m%d
today=20100120
+ echo %+ Today's date: 1/20/2010
+ ((  M = M - 1  ))
+ [ M -lt 1 ]
+ ((  Y = Y - 1  ))
+ ((  M = M + 12  ))
+ + printf %s%02d%02d 2009 12 1
fileDate=20091201
+ ((  M = M - 1  ))
+ [ M -lt 1 ]
+ + printf %s%02d%02d 2009 11 20
arcDate=20091120
+ echo %+ Archive date < 20091201
+ rm /nfsshare/Interface/AP/Outbound/Archive/Tar/tarFiles.tmp
+ touch -t 200912010001 /nfsshare/Interface/AP/Outbound/Archive/Tar/arc13815.tmp
+ TAR_DIR=/nfsshare/Interface/AP/Outbound/Archive/Tar/09
+ fileList=/nfsshare/Interface/AP/Outbound/Archive/Tar/tarFiles.tmp
+ [ ! -d /nfsshare/Interface/AP/Outbound/Archive/Tar/09 ]
+ tgzFile=20100120.AP.tgz
+ echo %+ TAR Dir/File: /nfsshare/Interface/AP/Outbound/Archive/Tar/09/20100120.AP.tgz
+ cd /nfsshare/Interface/AP/Outbound/Archive
+ find . ! -newer /nfsshare/Interface/AP/Outbound/Archive/Tar/arc13815.tmp -a ! -name *.tmp
+ 1> /nfsshare/Interface/AP/Outbound/Archive/Tar/tarFiles.tmp 2>& 1
+ [[ 0 -ne 0 ]]
+ gzip -c
+ tar cvf - -T /nfsshare/Interface/AP/Outbound/Archive/Tar/tarFiles.tmp
+ 1> /nfsshare/Interface/AP/Outbound/Archive/Tar/09/20100120.AP.tgz
a -T 5K
a /nfsshare/Interface/AP/Outbound/Archive/Tar/tarFiles.tmp 3K
+ [[ 0 -ne 0 ]]
+ find . ! -newer /nfsshare/Interface/AP/Outbound/Archive/Tar/arc13815.tmp -exec rm {} ;
rm: ./April is a directory
rm: ./August is a directory
rm: ./December is a directory
rm: ./February is a directory
rm: ./January is a directory
rm: ./July is a directory
rm: ./June is a directory
rm: ./March is a directory
rm: ./May is a directory
rm: ./November is a directory
rm: ./October is a directory
rm: ./September is a directory
+ [[ 0 -ne 0 ]]
+ rm /nfsshare/Interface/AP/Outbound/Archive/Tar/tarFiles.tmp
+ exit 0
 
 HERE IS THE LIST OF FILES TO TEST WITH:
va2ztsap012/nfsshare/Interface/AP/Outbound/Archive>> ls -al
total 47048
-rw-r--r--   1 fsrconnect sapsys      5120 Jan 19 18:10 -T
drwxrwxr-x  16 yq1adm   sapsys      8192 Jan 20 10:53 .
drwxrwxr-x   8 yq1adm   sapsys      4096 Oct 10 10:43 ..
-rw-r--r--   1 fsrconnect sapsys         0 Sep  1 18:26 090901.AP.tgz
-rw-r--r--   1 fsrconnect sapsys   4279516 Jan 20 10:53 091709.tgz.old
-rw-r-----   1 fsrconnect sapsys    973250 Aug 28 12:06 AP_VENDORMASTERTOMNF_01JUL2009.TXT
-rw-r-----   1 fsrconnect sapsys    973299 Aug 28 12:06 AP_VENDORMASTERTOMNF_02JUL2009.TXT
-rw-r-----   1 fsrconnect sapsys    973299 Aug 28 12:06 AP_VENDORMASTERTOMNF_03JUL2009.TXT
-rw-r-----   1 fsrconnect sapsys    970505 Aug  4 13:29 AP_VENDORMASTERTOMNF_04AUG2009.TXT
-rw-r-----   1 fsrconnect sapsys    973351 Jul  7  2009 AP_VENDORMASTERTOMNF_07JUL2009.TXT
-rw-r-----   1 fsrconnect sapsys   1031896 Jun  8  2009 AP_VENDORMASTERTOMNF_08JUN2009.TXT
-rw-r-----   1 fsrconnect sapsys    973392 Aug 28 12:06 AP_VENDORMASTERTOMNF_09JUL2009.TXT
-rw-r-----   1 fsrconnect sapsys    973546 Aug 28 12:06 AP_VENDORMASTERTOMNF_10JUL2009.TXT
-rw-r-----   1 fsrconnect sapsys    978712 Aug 12 13:49 AP_VENDORMASTERTOMNF_12AUG2009.TXT
-rw-r-----   1 fsrconnect sapsys    973542 Aug 28 12:06 AP_VENDORMASTERTOMNF_13JUL2009.TXT
-rw-r-----   1 fsrconnect sapsys   1034387 Jun 15  2009 AP_VENDORMASTERTOMNF_15JUN2009.TXT
-rw-r-----   1 fsrconnect sapsys   1035568 Jun 16  2009 AP_VENDORMASTERTOMNF_16JUN2009.TXT
-rw-r-----   1 fsrconnect sapsys    972196 Jun 18  2009 AP_VENDORMASTERTOMNF_18JUN2009.TXT
-rw-r-----   1 fsrconnect sapsys    972836 Jun 22  2009 AP_VENDORMASTERTOMNF_22JUN2009.TXT
-rw-r-----   1 fsrconnect sapsys    981446 Aug 24 18:07 AP_VENDORMASTERTOMNF_24AUG2009.TXT
-rw-r-----   1 fsrconnect sapsys    395782 May 26  2009 AP_VENDORMASTERTOMNF_26MAY2009.TXT
-rw-r-----   1 fsrconnect sapsys    809249 May 29  2009 AP_VENDORMASTERTOMNF_29MAY2009.TXT
-rw-r-----   1 fsrconnect sapsys    973250 Aug 28 12:06 AP_VENDORMASTERTOMNF_30JUN2009.TXT
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 April
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 August
-rw-r-----   1 fsrconnect sapsys    571019 Sep  1 18:36 BAP_OH01.CSV
-rw-r-----   1 fsrconnect sapsys         0 Aug 18 15:53 BO_PWR_ML_20090818160217Y_SP
-rw-r-----   1 fsrconnect sapsys       574 Aug 18 16:05 BO_PWR_ML_20090818160642Y_SP
-rw-r-----   1 fsrconnect sapsys       574 Aug 20 16:57 BO_PWR_ML_20090820165946Y_SP
-rw-r-----   1 fsrconnect sapsys     63395 Aug 20 17:28 BO_PWR_ML_20090820172845Y_SP
-rw-r-----   1 fsrconnect sapsys    217694 Aug 28 12:06 BofAPurchaseOrgVendorCombo.csv.arc
-rw-r-----   1 fsrconnect sapsys    468673 Aug 28 12:06 BofAVendor.csv.arc
-rw-r-----   1 fsrconnect sapsys      1219 Aug 28 12:06 DRAFT5_0010003196_2980_20090615_112217
-rw-r-----   1 fsrconnect sapsys      1339 Aug 28 12:06 DRAFT5_0010003196_2980_20090618_175244
-rw-r-----   1 fsrconnect sapsys      2659 Aug 28 12:06 DRAFT5_0010003196_2980_20090624_140442
-rw-r-----   1 fsrconnect sapsys       226 Aug 28 12:06 DRAFT5_0010003196_2980_20090625_092313
-rw-r-----   1 fsrconnect sapsys      4579 Aug 28 12:06 DRAFT5_0010003196_2980_20090625_115733
-rw-r-----   1 fsrconnect sapsys       739 Aug 28 12:06 DRAFT5_0010003196_2980_20090626_165922
-rw-r-----   1 fsrconnect sapsys       739 Aug 28 12:06 DRAFT5_0010003196_2980_20090701_000100
-rw-r-----   1 fsrconnect sapsys       739 Aug 28 12:06 DRAFT5_0010003196_2980_20090702_000014
-rw-r-----   1 fsrconnect sapsys       739 Aug 28 12:06 DRAFT5_0010003196_2980_20090703_000023
-rw-r-----   1 fsrconnect sapsys       859 Aug 28 12:06 DRAFT5_0010003196_2980_20090707_154846
-rw-r-----   1 fsrconnect sapsys       739 Aug 28 12:06 DRAFT5_0010003196_2980_20090710_000045
-rw-r-----   1 fsrconnect sapsys       859 Jul 11  2009 DRAFT5_0010003196_2980_20090711_000007
-rw-r-----   1 fsrconnect sapsys       859 Jul 14  2009 DRAFT5_0010003196_2980_20090714_092320
-rw-r-----   1 fsrconnect sapsys       859 Jul 14  2009 DRAFT5_0010003196_2980_20090714_093159
-rw-r-----   1 fsrconnect sapsys      1459 Aug 28 12:06 DRAFT5_0010004770_2980_20090529_135719
-rw-r-----   1 fsrconnect sapsys      1459 Aug 28 12:06 DRAFT5_0010004781_2374_20090529_161225
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 December
-rw-r-----   1 fsrconnect sapsys      1567 Aug 28 12:06 EFT-2941-CAD_20090702_210021
-rw-r-----   1 fsrconnect sapsys      1282 Aug 28 12:06 EFT-2941-CAD_20090707_145003
-rw-r-----   1 fsrconnect sapsys       997 Aug 28 12:06 EFT-2941-CAD_20090710_210031
-rw-r-----   1 fsrconnect sapsys       427 Aug 28 12:06 EFT-2941-CAD_20090713_170242
-rw-r-----   1 fsrconnect sapsys      1852 Aug 28 12:06 EFT-2941-CAD_20090721_130053
-rw-r-----   1 fsrconnect sapsys       997 Aug 28 12:06 EFT-2941-USD_20090702_210024
-rw-r-----   1 fsrconnect sapsys       712 Aug 28 12:06 EFT-2941-USD_20090710_210034
-rw-r-----   1 fsrconnect sapsys       712 Aug 28 12:06 EFT-2941-USD_20090713_162544
-rw-r-----   1 fsrconnect sapsys       997 Aug 28 12:06 EFT-2941-USD_20090721_130058
-rw-r-----   1 fsrconnect sapsys      1276 Aug 28 12:06 EFT-2980-CAD_20090702_210021
-rw-r-----   1 fsrconnect sapsys       421 Aug 28 12:06 EFT-2980-CAD_20090703_210039
-rw-r-----   1 fsrconnect sapsys       991 Aug 28 12:06 EFT-2980-CAD_20090707_144132
-rw-r-----   1 fsrconnect sapsys       706 Aug 28 12:06 EFT-2980-CAD_20090709_210112
-rw-r-----   1 fsrconnect sapsys      1561 Aug 28 12:06 EFT-2980-CAD_20090710_210033
-rw-r-----   1 fsrconnect sapsys       706 Aug 28 12:06 EFT-2980-CAD_20090713_162539
-rw-r-----   1 fsrconnect sapsys      2131 Aug 28 12:06 EFT-2980-CAD_20090721_130055
-rw-r-----   1 fsrconnect sapsys       421 Aug 28 12:06 EFT-2980-USD_20090702_210024
-rw-r-----   1 fsrconnect sapsys       421 Aug 28 12:06 EFT-2980-USD_20090707_144138
-rw-r-----   1 fsrconnect sapsys       706 Aug 28 12:06 EFT-2980-USD_20090710_210036
-rw-r-----   1 fsrconnect sapsys       706 Aug 28 12:06 EFT-2980-USD_20090713_162542
-rw-r-----   1 fsrconnect sapsys      1276 Aug 28 12:06 EFT-2980-USD_20090721_130059
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 February
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 January
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 July
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 June
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 March
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 May
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 November
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 October
-rw-r-----   1 fsrconnect sapsys      1275 Sep  1 18:36 S_BAP_OH01.CSV
-rw-r-----   1 fsrconnect sapsys      1275 Aug  6 10:27 S_ZAP_OH01.CSV
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep 17 16:47 September
-rw-r-----   1 fsrconnect sapsys       561 Aug 18 14:04 TSYS_DRAFT5_20090818_140431
-rw-r-----   1 fsrconnect sapsys      1281 Aug 27 12:41 TSYS_DRAFT5_20090827_124100
-rw-r-----   1 fsrconnect sapsys       561 Sep  3 15:51 TSYS_DRAFT5_20090903_155144
-rw-r-----   1 fsrconnect sapsys       681 Sep  4 09:14 TSYS_DRAFT5_20090904_091416
-rw-r-----   1 fsrconnect sapsys       681 Sep  4 17:09 TSYS_DRAFT5_20090904_150000
drwxr-xr-x   5 fsrconnect sapsys      8192 Jan 20 10:50 Tar
-rw-r-----   1 fsrconnect sapsys    149861 Aug  6 10:27 ZAP_OH01.CSV
-rw-r-----   1 fsrconnect sapsys     36058 Aug 28 12:06 ZO_FIG_MLY_SPND_REP_20090624155124.CSV
-rw-r-----   1 fsrconnect sapsys         0 Jun 24  2009 ZO_PWR_MLY_SPND_REP_20090624230553.CSV
-rw-r-----   1 fsrconnect sapsys         0 Jun 25  2009 ZO_PWR_MLY_SPND_REP_20090625081904.CSV
-rw-r-----   1 fsrconnect sapsys         0 Jun 26  2009 ZO_PWR_MLY_SPND_REP_20090626124841.CSV
-rw-r-----   1 fsrconnect sapsys         0 Jun 30  2009 ZO_PWR_MLY_SPND_REP_20090630025631.CSV
-rw-r-----   1 fsrconnect sapsys         0 Jun 30  2009 ZO_PWR_MLY_SPND_REP_20090630100023.CSV
-rw-r-----   1 fsrconnect sapsys         0 Jun 30  2009 ZO_PWR_MLY_SPND_REP_20090630102505.CSV
-rw-r-----   1 fsrconnect sapsys    351527 Jun 30  2009 ZO_PWR_MLY_SPND_REP_20090630103413.CSV
-rw-r-----   1 fsrconnect sapsys     57380 Jul  1  2009 ZO_PWR_MLY_SPND_REP_20090701021746.CSV
-rw-r-----   1 fsrconnect sapsys     20730 Jul  2  2009 ZO_PWR_MLY_SPND_REP_20090702025120.CSV
-rw-r-----   1 fsrconnect sapsys     23111 Aug 28 12:06 ZO_PWR_MLY_SPND_REP_20090703030210.CSV
-rw-r-----   1 fsrconnect sapsys    415011 Jul  3  2009 ZO_PWR_MLY_SPND_REP_20090703103916.CSV
-rw-r-----   1 fsrconnect sapsys     15062 Jul  8  2009 ZO_PWR_MLY_SPND_REP_20090708114432.CSV
drwxr-xr-x   2 fsrconnect sapsys      4096 Jan 19 17:56 test

 
HERE IS THE RESULT:
 va2ztsap012/nfsshare/Interface/AP/Outbound/Archive>> ls -al
total 160
-rw-r--r--   1 fsrconnect sapsys      5120 Jan 19 18:10 -T
drwxrwxr-x  16 yq1adm   sapsys      8192 Jan 20 10:55 .
drwxrwxr-x   8 yq1adm   sapsys      4096 Oct 10 10:43 ..
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 April
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 August
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 December
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 February
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 January
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 July
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 June
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 March
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 May
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 November
drwxr-xr-x   2 fsrconnect sapsys      4096 Sep  1 13:48 October
drwxr-xr-x   2 fsrconnect sapsys      4096 Jan 20 10:55 September
drwxr-xr-x   5 fsrconnect sapsys      8192 Jan 20 10:55 Tar
drwxr-xr-x   2 fsrconnect sapsys      4096 Jan 19 17:56 test

  cd 09
va2ztsap012/nfsshare/Interface/AP/Outbound/Archive/Tar/09>> ls -al
total 56
-rw-r--r--   1 fsrconnect sapsys      5120 Jan 19 18:10 -T
drwxr-xr-x   2 fsrconnect sapsys      4096 Jan 20 10:55 .
drwxr-xr-x   5 fsrconnect sapsys      8192 Jan 20 10:55 ..
-rw-r--r--   1 fsrconnect sapsys      1083 Jan 19 18:25 20100119.AP.tgz
-rw-r--r--   1 fsrconnect sapsys      1091 Jan 20 10:55 20100120.AP.tgz
va2ztsap012/nfsshare/Interface/AP/Outbound/Archive/Tar/09>>

NOTE ===THE ONLY FILE CREATED WAS  20100120.AP.tgz
***Here's the out put when I untar it:
va2ztsap012/nfsshare/Interface/AP/Outbound/Archive/Tar/09>> gunzip -c 20100120.AP.tar | tar xvf -
x -T, 5120 bytes, 10 tape blocks
x /nfsshare/Interface/AP/Outbound/Archive/Tar/tarFiles.tmp, 3038 bytes, 6 tape blocks

I cant find any files...lol
 
Thanks
 
 
0
 
HIONSPDAuthor Commented:
Mike,
The only file that gets compress and tar up is the  tarFiles.tmp all the other files just get removed.
0
 
MikeOM_DBACommented:
Show me your script.
There is something wrong wit this:
...../Archive/Tar/09/20100120.AP.tgz
 
0
 
HIONSPDAuthor Commented:
Here you go:

va2ztsap012/home/fsrconnect/carlos/scripts>> more ap_arc.ksh
#!/usr/bin/ksh
# ...Blah, Blah, Blah...

# SORT PROFILE FILE
. /home/fsrconnect/autosys/common/profile_bourne

##---------------------------------------------
## Month Array + Misc variables
set -A month "none" "January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December"

set -A dt `date +%Y\ %m\ %d`

typeset -i Y=${dt[0]}
typeset -i M=${dt[1]}
typeset -i D=${dt[2]}
today=`date +%Y%m%d`
echo "%+ Today's date: $M/$D/$Y"
(( M = M - 1 ))
if [ M -lt 1 ]
then
  (( Y = Y - 1 )); (( M = M + 12 ))
fi
fileDate=`printf "%s%02d%02d" $Y $M 1`
(( M = M - 1 ))
if [ M -lt 1 ]
then
  (( Y = Y - 1 )); (( M = M + 12 ))
fi
arcDate=`printf "%s%02d%02d" $Y $M $D`
echo "%+ Archive date < $fileDate"
rm ${TAR_AP}/*.tmp #*/
touch -t ${fileDate}0001 ${TAR_AP}/arc$$.tmp
TAR_DIR="${TAR_AP}/${month[$M]}${Y#??}"
fileList=${TAR_AP}/tarFiles.tmp
[ ! -d $TAR_DIR ] && mkdir -p $TAR_DIR
tgzFile="${dt[0]}${dt[1]}${dt[2]}.AP.tgz"
echo "%+ TAR Dir/File: $TAR_DIR/$tgzFile"

##---------------------------------------------
## AP

cd $AP_ARC

find . ! -newer ${TAR_AP}/arc$$.tmp -a ! -name '*.tmp' >$fileList 2>&1
if [[ $? -ne 0 ]] ; then
  echo "!ERROR $?: THERE ARE NO FILES OLDER THAN $M/$D/$Y TO ARCHIVE AT THE MOMENT. "
  exit 39
fi
tar cvf - -T $fileList | gzip -c > ${TAR_DIR}/$tgzFile
if [[ $? -ne 0 ]] ; then
  echo "!ERROR $?: TAR AND COMPRESSION OF THE AP FILES NOT EXECUTED. "
  exit 40
fi

find . ! -newer ${TAR_AP}/arc$$.tmp -exec rm {} \;
if [[ $? -ne 0 ]] ; then
  echo "!ERROR $?: NOT ABLE TO REMOVE FILES FROM AP DIRECTORY. "
  exit 41
fi

rm ${TAR_AP}/*.tmp
exit 0
0
 
HIONSPDAuthor Commented:
Please notice also on the creation of a -T file on the archive directory...I cant rm it

va2ztsap012/nfsshare/Interface/AP/Outbound/Archive>> ls -al
total 160
-rw-r--r--   1 fsrconnect sapsys      5120 Jan 19 18:10 -T
drwxrwxr-x  16 yq1adm   sapsys      8192 Jan 20 10:55 .
drwxrwxr-x   8 yq1adm   sapsys      4096 Oct 10 10:43 ..
** maybe it has something to do with this step:
tar cvf - -T $fileList | gzip -c > ${TAR_DIR}/$tgzFile
0
 
MikeOM_DBACommented:
rm "-T"
Very weird that it creates a '-T' file, check the tar options for your OS version (man tar), the -T option should indicate the name of a file containing the list of files to tar.
 
 
 
0
 
HIONSPDAuthor Commented:
va2ztsap012/home/fsrconnect/carlos>> uname -a
SunOS va2ztsap012 5.10 Generic_127127-11 sun4u sparc SUNW,SPARC-Enterprise
0
 
HIONSPDAuthor Commented:
User Commands                                              tar(1)

     T              This modifier is only available if the system
                    is configured with Trusted Extensions.

                    When this modifier is used with the  function
                    letter  c, r, or u for creating, replacing or
                    updating a  tarfile,  the  sensitivity  label
                    associated with each archived file and direc-
                    tory is stored in the tarfile.

                    Specifying T implies the function modifier p.

                    When used with  the  function  letter  x  for
                    extracting  a  tarfile, the tar program veri-
                    fies that the file's sensitivity label speci-
                    fied  in  the  archive equals the sensitivity
                    label of the destination directory.  If  not,
                    the file is not restored. This operation must
                    be invoked  from  the  global  zone.  If  the
                    archived  file has a relative pathname, it is
                    restored to the corresponding directory  with
                    the same label, if available. This is done by
                    prepending to the current destination  direc-
                    tory  the  root  pathname  of  the zone whose
                    label  equals  the  file.  If  no  such  zone
                    exists, the file is not restored.

                    Limited support is  provided  for  extracting
                    labeled archives from Trusted Solaris 8. Only
                    sensitivity labels, and multi-level directory
                    specifications   are  interpreted.  Privilege
                    specifications and audit attribute flags  are
                    silently    ignored.   Multilevel   directory
                    specifications including  symbolic  links  to
                    single  level directories are are mapped into
                    zone-relative pathnames if a  zone  with  the
                    same  label  is  available.  This  support is
                    intended  to  facilitate  migration  of  home
                    directories.  Architectural  differences pre-
                    clude the extraction of  arbitrarily  labeled
                    files  from Trusted Solaris 8 into  identical
                    pathnames in Trusted Extensions. Files cannot
                    be  extracted  unless  their  archived  label
                    matches the destination label.
0
 
MikeOM_DBACommented:
That's the issue.
Find the option that tells tar that the list of files to "tar" is contained in a file.
 
0
 
MikeOM_DBACommented:
Ok found it for you, replace -t with -I
 From: docs.sun.com Home  > Solaris 10 Reference Manual Collection  > man pages section 1: User Commands  > User Commands  > tar(1) – create tape archives and add or extract files
-I include-file

Opens include-file containing a list of files, one per line, and treats it as if each file appeared separately on the command line. Be careful of trailing white spaces. Also beware of leading white spaces, since, for each line in the included file, the entire line (apart from the newline) will be used to match against the initial string of files to include. In the case where excluded files (see X function modifier) are also specified, they take precedence over all included files. If a file is specified in both the exclude-file and the include-file (or on the command line), it will be excluded. file
A path name of a regular file or directory to be archived (when the c, r or u functions are specified), extracted (x) or listed (t). When file is the path name of a directory, the action applies to all of the files and (recursively) subdirectories of that directory.
When a file is archived, and the E flag (see Function Modifiers) is not specified, the filename cannot exceed 256 characters. In addition, it must be possible to split the name between parent directory names so that the prefix is no longer than 155 characters and the name is no longer than 100 characters. If E is specified, a name of up to PATH_MAX characters may be specified.
For example, a file whose basename is longer than 100 characters could not be archived without using the E flag. A file whose directory portion is 200 characters and whose basename is 50 characters could be archived (without using E) if a slash appears in the directory name somewhere in character positions 151-156.
 
0
 
HIONSPDAuthor Commented:
Yep ... that did it ..!!!!

GREAT Thanks Mike...!!!!
Here's the final version:

#!/usr/bin/ksh
# ...Blah, Blah, Blah...

# SORT PROFILE FILE
. /home/fsrconnect/autosys/common/profile_bourne

##---------------------------------------------
## Month Array + Misc variables
set -A month "none" "January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December"

set -A dt `date +%Y\ %m\ %d`

typeset -i Y=${dt[0]}
typeset -i M=${dt[1]}
typeset -i D=${dt[2]}
today=`date +%Y%m%d`
echo "%+ Today's date: $M/$D/$Y"
(( M = M - 1 ))
if [ M -lt 1 ]
then
  (( Y = Y - 1 )); (( M = M + 12 ))
fi
fileDate=`printf "%s%02d%02d" $Y $M 1`
(( M = M - 1 ))
if [ M -lt 1 ]
then
  (( Y = Y - 1 )); (( M = M + 12 ))
fi
arcDate=`printf "%s%02d%02d" $Y $M $D`
echo "%+ Archive date < $fileDate"
rm ${TAR_AP}/*.tmp #*/
touch -t ${fileDate}0001 ${TAR_AP}/arc$$.tmp
TAR_DIR="${TAR_AP}/${month[$M]}${Y#??}"
fileList=${TAR_AP}/tarFiles.tmp
[ ! -d $TAR_DIR ] && mkdir -p $TAR_DIR
tgzFile="${dt[0]}${dt[1]}${dt[2]}.AP.tgz"
echo "%+ TAR Dir/File: $TAR_DIR/$tgzFile"

##---------------------------------------------
## AP

cd $AP_ARC

find . ! -newer ${TAR_AP}/arc$$.tmp -a ! -name '*.tmp' >$fileList 2>&1
if [[ $? -ne 0 ]] ; then
  echo "!ERROR $?: THERE ARE NO FILES OLDER THAN $M/$D/$Y TO ARCHIVE AT THE MOMENT. "
  exit 39
fi
tar cvf - -I $fileList | gzip -c > ${TAR_DIR}/$tgzFile
if [[ $? -ne 0 ]] ; then
  echo "!ERROR $?: TAR AND COMPRESSION OF THE AP FILES NOT EXECUTED. "
  exit 40
fi

find . ! -newer ${TAR_AP}/arc$$.tmp -exec rm {} \;
if [[ $? -ne 0 ]] ; then
  echo "!ERROR $?: NOT ABLE TO REMOVE FILES FROM AP DIRECTORY. "
  exit 41
fi

rm ${TAR_AP}/*.tmp
exit 0

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 21
  • 14
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now