Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gzip arc files

Status
Not open for further replies.

m2001331

Technical User
May 29, 2002
73
0
0
MY
Hi,

How can i gzip arc files - i mean i want to be able to call the gzip from a cron say twice a day to gzip all the arc file - i am also concerned that it might gzip an *arc file that is being written to at the point of gzip.How do i prevent this from happening.
please advise.are there any scripts which i can use as guideline?

thanks and regards.
 
I have the following script in cron:

cd <archive directory>
ls | grep -v gz | grep -v loglist> loglist
lines=`wc -l loglist | tr -s ' ' ' ' | cut -f2 -d ' '`
if [ $lines -gt 1 ]
then
head -`expr $lines - 1` loglist > loglist1
for file in `cat loglist1`
do
gzip $file 2> /dev/null
done
fi


This basically takes all but the last log written and gzips them , leaving the latest (which as you say is possibly being written to) intact. I run this every five minutes, but this is possibly overkill if your system isn't writing logs at that rate. Hope this helps.
 
Hi,

thanx for the script - i had replaced the cd<directory> with correct path and put it in a *.sh file and place it in usr/local/cron.
i tried to run it - but it gave me a 0403-006:execute permission denied.

the same message appears when i run it as either root or oracle.
please advise.

thanks.
 
you need to grant execute permissions to the file. You may need to do this ar root or whoever owns the file

chown oracle:dba

when you do an ls -l it should an 'x' in the 4th column from left.

ie:

-rwx <-- these are the permissions r=read w=write x=execute

hth sy

Sy UK
 
Sy is correct. I run the compress from root, with permissions of 755 on the script, ie:

chmod 755 <scriptname>

Hope this helps.
 
Hi.
I'd create the loglist reverse sorted by modification time when using Kens script. So the second line would read:
Code:
...
ls -rt | grep -v gz | grep -v loglist> loglist
...
This way you're independant of the log_archive_format (and log sequence numbers...).

Stefan
 
Good call Stefan, I've changed mine to include the -rt too. Not sure why I didn't do that in the first place!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top