The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Insert file names when concatenate files into a file samky2005 Shell Programming and Scripting 2 06-05-2009 07:07 PM
find locked files, print file path, unlock file alternapop UNIX for Dummies Questions & Answers 0 04-14-2009 09:09 PM
ls > file - Creating file containing the list of all files present in a directory pranavagarwal Shell Programming and Scripting 1 09-26-2008 09:37 PM
listing files excluding files from control file ukatru UNIX for Advanced & Expert Users 15 08-15-2008 09:24 PM
total number of files which have "aaa" in files whose names are File*_bbb* sudheshnaiyer UNIX for Dummies Questions & Answers 1 08-16-2007 03:34 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-01-2009
percvs88 percvs88 is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 8
zip all of files except last file

hi, I try to write a script to zip archivelog files in arch fold except not zip last archivelog file since it database may be still using the last file
here is my script. when I run the script, I get error messages. could you please advise/correct my script in detail what it could be wrong, I am not expert for shell script, it could be simple mistake, but just don't know.

thanks very much for your help.
jack

here is my script:

ORACLE_SID="vprod"
BACK_DIR=`/oraappl/pca/backups`
export ORACLE_SID BACK_DIR

program=`basename $0`
DBAPAGE="/oraappl/pca/vprod/vprodscr/bin/dba_pager.ksh"
$DBAPAGE "$program:$ORACLE_SID:start" "Starting archivelog backup at `date` for $ORACLE_SID"
LOGFILE=$BACK_DIR/nightly_offsite/log/${ORACLE_SID}_archbackup.log
BCKFILE=$BACK_DIR/nightly_offsite/${ORACLE_SID}_arch.`date +%m%d%y`.gz
echo "Archive log backup for $ORACLE_SID on `date` started"
ALLLOGS=`ls -rt`
LASTLOG=`echo "$ALLLOGS" |tail -1`
SECONDLASTLOG=`echo "$ALLLOGS" |tail -2 | head -n 1`
echo "First log is: "`echo "$ALLLOGS" | head -n 1`
echo "Second Last log is : "`echo "$ALLLOGS" |tail -2 | head -n 1`
echo "Exclude Last log is : "`echo "$ALLLOGS" |tail -1`
echo "Command is: /usr/local/bin/gtar -zcvf $BCKFILE" $ALLLOGS "-X" $LASTLOG
find $BACK_DIR/nightly_offsite -name "${ORACLE_SID}_arch*" -depth -type f -mtime +5 -exec rm {} \;
/usr/local/bin/gtar -zcvf $BCKFILE $ALLLOGS -X $LASTLOG

echo "Archive log backup for $ORACLE_SID on `date` completed"
$DBAPAGE "$program:$ORACLE_SID:end" "Ending archivelog backup at `date` for $ORACLE_SID"
exit


here is the error message when I run above script:

$ . ./archbackup.ksh
basename $0:vprod:start Starting archivelog backup at 'date' for vprod
Archive log backup for vprod on 'date' started
Frist log is: echo "$ALLLOGS" | head -n 1
Second Last Log is: echo "$ALLLOGS" |tail -2 |head -n 1
Exclude Last Log is: echo "$ALLLOGS" |tail -1
Command is: gtar -zcvf /oraappl/pca/backups/nightly_offsite/vprod_arch.date +%m%d%y.gz ls -rt -X each "$ALLLOGS" |tail -1
gtar: +%m%d%y.gz: Cannot stat: No such file or directory
gtar: ls: Cannot stat: No such file or directory
gtar: -rt: Cannot stat: No such file or directory
gtar: -X: Cannot stat: No such file or directory
gtar: each: Cannot stat: No such file or directory
gtar: "$ALLLOGS": Cannot stat: No such file or directory
gtar: |tail: Cannot stat: No such file or directory
gtar: -1: Cannot stat: No such file or directory
gtar: Error exit delayed from previous errors
Archive log backup for vprod on 'date' completed
basename $0:vprod:end Ending archivelog backup at 'date' for vprod
$
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0