- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Cron Script - Archieving and Zipping Oracle Files
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2001 02:21 PM
06-01-2001 02:21 PM
I have this script that runs every hour which
takes archive Oracle Logs and "zips" them
every 24 hours.
Well the problem is we need to zip them more often (we had our disks fill up) so we would like this done every 5 minutes instead of every 24 hours....
however, we like to "nice" the process so that
"zipping" does not interfere with production
processing.
Also is there a way to verify that the archieving/ copying is done before I start
zipping. I don't want to zip the file before
it is done being archieved. I don't think
we should have the "find" command in the script, but I would love your help here...
Here's the current Script:
# set vars
. ~/.profile > /dev/null 2>&1
ARCHPATH=/db04/oradata/${ORACLE_SID}/arch/
# log start time
echo ------------------------------------------echo "begin."; date
echo "checking ${ARCHPATH}..."
# for each .ARC file that is older than one day, zip it!
for vlc_gzfile in `find $ARCHPATH -name '*.ARC' -mtime 1`
do
echo "gzipping ${vlc_gzfile}..."
/usr/contrib/bin/gzip ${vlc_gzfile}
done
echo "done."; date
Many many thanks for your help...
Script Challenged..Laurie
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2001 03:01 PM
06-01-2001 03:01 PM
SolutionSeveral comments:
> I've done something similar before. In my script I chose to drive the collection of files to archive using 'ls -lrt' to reverse the normal order and give a descending collation or oldest modified file first. I then explicity *skipped* the first file returned, thereby always leaving the most current file on disk.
> Your use of the -mtime with 'find' is probably OK since the '-mtime' option is 24-hour based.
> You should be able to test the return value of 'gzip' to insure success. Something like:
# if [ $? -eq 0 ]
# then
#...zipped_ok...
# else
#...handle error...
# fi
I trust you find this useful [no pun intended! ;-) ].
With my regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2001 06:11 AM
06-04-2001 06:11 AM
Re: Cron Script - Archieving and Zipping Oracle Files
I don't want to use the -mtime with find since
it's 24 hour based...I want it to run every
5 minutes.
I'm not sure how the error handling would
work here.
Thanks,
laurie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2001 06:28 AM
06-04-2001 06:28 AM
Re: Cron Script - Archieving and Zipping Oracle Files
Take a look at the man pages for 'find'. You'll see the option '-newer'. You can create a reference file with whatever time and date you want (with 'touch') and use it to drive your 'find' if you'd like to do it that way.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2001 06:51 AM
06-04-2001 06:51 AM
Re: Cron Script - Archieving and Zipping Oracle Files
this from cron every 5 minutes. Does it look
OK?
# for each .ARC file - find the oldest file and zip it!
for vlc_gzfile in `find $ARCHPATH -name '*.ARC' -ls -lrt`
do
echo "gzipping ${vlc_gzfile}..."
/usr/contrib/bin/gzip ${vlc_gzfile}
if [$? -eq 0]
then zipped_ok
else
handle_error
if
done
handle_error
echol 1>$&2 vlc_gzfile Not Zipped
echo "done."; date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2001 07:08 AM
06-04-2001 07:08 AM
Re: Cron Script - Archieving and Zipping Oracle Files
Here's an example of using the '-newer' option of 'find'. Suppose I want to find all files named "*.out" in the /tmp directory where the modification timestamp is older than June 1 at 1300 hours. I could write:
# touch -mt 06011300 /tmp/reffile
# find /tmp -name *.out ! -newer /tmp/reffile
I have attached the "guts" of the archive script I used to 'tar' Oracle logs. See if that helps you, choose the methodlogy you like.
With my regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2001 12:26 PM
06-04-2001 12:26 PM
Re: Cron Script - Archieving and Zipping Oracle Files
I'll give you another way to test if a file is quiescent. I use a perl script called fileage.pl. It returns a status of zero if the file has not been touched in the last few seconds (default 60). You would use it like this:
myfile=arch230.dbf
fileage.pl -s 120 $myfile
STAT=$?
if [ ${STAT} - eq 0 ]
then
echo "${myfile} has not been changed \c"
echo "in the last 120 seconds"
gzip ${myfile}
fi
If you invoke fileage.pl without args, it gives you a full usage message. It's a fairly handy little script fdor checking if it's safe to copy/move/compress a file.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2001 05:57 AM
06-05-2001 05:57 AM
Re: Cron Script - Archieving and Zipping Oracle Files
1. How do I tell if I have Perl installed
so I can write Perl scripts?
2. Does Cron invoke Perl scripts the same
way as regular scripts? Do I have to do
any thing special?
I only hear good things about Perl, so many
I should install this on all my servers.
Laurie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2001 06:14 AM
06-05-2001 06:14 AM
Re: Cron Script - Archieving and Zipping Oracle Files
To test whether perl is installed, simply do a 'type perl'. Perl is almost alway installed on HP boxes but the version that HP distributes is often quite old. I would obtain
the latest version (and you can get the binaries so that you don't need to compile.)
Here's the URL:
http://hpux.cs.utah.edu/hppd/hpux/Languages/perl-5.6.1/
Since you seem fairly new to UNIX, I would say
after you are reasonably proficient in the shell, I would then definitely learn perl.
If you know perl (and I shudder when I say this) there is really no need to know awk, sed,
grep, etc. since essentially anything you can do in these, you can do in perl. I'm not saying you shouldn't be able to awk but rather you could learn just perl well and not HAVE to know the others. The other good thing about perl is that it runs on WindowsXX, W2K, and NT as well. In fact, it's very easy to setup bidirectional sockets, for example, between a windows box and a unix box with just a few lines of perl.
Clay