INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Any input will be "YUGELLY" appreciated!!

Any input will be "YUGELLY" appreciated!!

(OP)
Hello All,
Plase your additional input will be "YUGELLY" appreciated :)

Requirements:
1) On the first day of each month, zip and create a tar file from existing *aud files.
2) On everyday thereafter, compress new *aud files and append it to the to the existing tar file created in (1).


#!/bin/ksh
#ScriptName:copy_zip_tar.sh

#SetInter-FieldSeparatortocolon.Simplifiesparsingtheinputfile.
IFS=:

cat/etc/oratab|whilereadORA_SIDORA_HOMEORA_START

fmonth=`date'+%d'`

if[$fmonth==01]
do
#find/orahome/app/oracle/admin/${ORA_SID}/adump-mtime+7-execrm{}\;
#candothefollowingfortesting...
find/orahome/app/oracle/admin/${ORA_SID}/adump/*-mtime+7-ls

tar cvf-/orahome/app/oracle/admin/${ORA_SID}/adump/*aud|gzip-c > ${ORA_SID}_aud_files_$(date'+%Y%m%d').tar.gz
else
tar cvf-/orahome/app/oracle/admin/${ORA_SID}/adump/*aud|gzip-c > /orahome/app/oracle/admin/${ORA_SID}/adump/{ORA_SID}_aud_files_$(date'+%B%Y').tar.gz
done
exit

RE: Any input will be "YUGELLY" appreciated!!

(OP)
Hello, I will really apreciate your input, the code as written below is giving me error:

/copy_zip_tar.sh[7]: syntax error at line 19 : `else' unexpected

CODE --> script

#! /bin/ksh
# Script Name: copy_zip_tar.sh

# Set Inter-Field Separator to colon. Simplifies parsing the input file.
IFS=:

cat /etc/oratab | while read ORA_SID ORA_HOME ORA_START

fmonth=`date '+%d'`

if [ $fmonth == 01 ]
{
#  find /orahome/app/oracle/admin/${ORA_SID}/adump  -mtime +7 -exec rm {} \;
# can do the following for testing...
  find /orahome/app/oracle/admin/${ORA_SID}/adump/* -mtime +7 -ls

  tar cvf - /orahome/app/oracle/admin/${ORA_SID}/adump/*aud | gzip -c > ${ORA_SID}_aud_files_$(date '+%Y%m%d').tar.gz
else
   tar cvf - /orahome/app/oracle/admin/${ORA_SID}/adump/*aud | gzip -c > /orahome/app/oracle/admin/${ORA_SID}/adump/{ORA_SID}_aud_file
s_$(date '+%B%Y').tar.gz
}
fi
exit 

RE: Any input will be "YUGELLY" appreciated!!

1. Why curly braces?
2. Where is "then" after "if"?

RE: Any input will be "YUGELLY" appreciated!!

(OP)
Below is the modified version.
Question - is this the correct best practices?
Given the requirement:
1) On the first day of each month, zip and create a tar file from existing *aud files.
2) On everyday thereafter, compress new *aud files and append it to the to the existing tar file created in (1).


CODE --> Shell

#! /bin/ksh
# Script Name: copy_zip_tar.sh

# Set Inter-Field Separator to colon. Simplifies parsing the input file.
IFS=:

cat /etc/oratab | while read ORA_SID ORA_HOME ORA_START
do
fmonth=`date '+%d'`

if [ $fmonth == 01 ]
then
#  find /orahome/app/oracle/admin/${ORA_SID}/adump  -mtime +7 -exec rm {} \;
# can do the following for testing...
  find /orahome/app/oracle/admin/${ORA_SID}/adump/* -mtime +7 -ls

  tar cvf - /orahome/app/oracle/admin/${ORA_SID}/adump/*aud | gzip -c > ${ORA_SID}_aud_files_$(date '+
%Y%m%d').tar.gz
else
   tar cvf - /orahome/app/oracle/admin/${ORA_SID}/adump/*aud | gzip -c > /orahome/app/oracle/admin/${O
RA_SID}/adump/{ORA_SID}_aud_files_$(date '+%B%Y').tar.gz
fi
done
exit 

RE: Any input will be "YUGELLY" appreciated!!

So does it work now?
As to the best practices, everyone chooses what works best for the task at hand. If it efficiently does what you need, is easy to maintain and meets your company standards, that should do.
I would consider using variables in place of long directory names having assigned these at the top of the script, and using ${long_var_name} instead of $long_var_name notation.

RE: Any input will be "YUGELLY" appreciated!!

Quote:


Question - is this the correct best practices?
Given the requirement:
1) On the first day of each month, zip and create a tar file from existing *aud files.
2) On everyday thereafter, compress new *aud files and append it to the to the existing tar file created in (1).

There isn't a particularly "global" best practice, just what suits your requirement the best.

Personally for my email backup (Done weekly), I update a tar Sunday through to Friday then update, compress then archive on the Saturday, rename the previous week's tar and create a new tar.

update the tar

CODE --> shell

tar -uf archive.tar folder-name/ 
( Sunday - Friday)

Final update then compress the tar and date and relocate it. (Saturday)

CODE --> shell

# update
  tar -uf archive.tar folder-name/ 
# compress
  gzip archive.tar
# set date and archive
  DATE=$(date +%Y%m%d)
  mv archive.tar.gz archive/$DATE.tar.gz
# backup current week
  mv archive.tar archive.old.tar
# create new
  tar -cf archive.tar folder-name/ 

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close