Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Need Script to Trigger Archive Log Cleanups

Re: Need Script to Trigger Archive Log Cleanups

From: Steven Lembark <>
Date: Thu, 16 May 2002 09:15:46 -0800
Message-ID: <>

> I need a routine which removes archive logs via RMAN tape backups if the
> archive log destination exceeds half full. I already have the RMAN part
> which we can kick off manually but I'm looking for something like a basic
> cron job monitoring script which triggers this based on the half full
> condition. Before I get started on this, does anyone have a script like
> this which they'd be willing to share? I figured I'd do a df with awk or
> Perl... but I'd rather just piggyback on someone else' fine script. :-)
> Other ideas?

Simple enough to do in perl with a regex:

    my $mountpoint = "/some/dir";
    my $cutoff = 50;

    my ($used) = qx( df $mountpoint ) =~ /(\d+)%/;

    if( $used > $cutoff )

        print "$$: Disk use on $mountpoint: $used > $cutoff";

        # whatever you want down here

        print "$$: $mountpoint below $cutoff";     }

For multiple mountpoints iterate on df:

    my @mountz = qw( /foo /bar /bletch );     my $cutoff = 50;

    my @overz =

        my ($used, $dir) = /(\d+)%\s+(.+)/;
        $used > $cutoff ? $dir : ()

    qx( df @mountz );

    for my $dir ( @overz )

        print "$$: Cleaning up $dir...";

        # whatever

the map combines the extraction with a grep to remove items that are blow the threshold. @overz is syntatic sugar, since the map could have cleaned everything up for itself:

    my @roadkill =

        my( $u, $d ) = /(\d+)%\s+(.+)/;
        if( $u > $cutoff )
            # cleanup $d...

            eval{ blah blah };
            $@ ? $@ : ()

    qx( df @mountz );

    print STDERR "$$: Bad news, boss, cleanups failed:", @roadkill

        if( @roadkill );

The eval leaves any messages from "die" in $@, which then get passed up to @roadkill. That or pass on a "was clean" message and change the array to "@results" or something.

Steven Lembark                               2930 W. Palmer
Workhorse Computing                       Chicago, IL 60647
                                            +1 800 762 1582

Content-Type: text/plain; name="ReadMe.txt"; charset="us-ascii" Content-Transfer-Encoding: 7bit The previous attachment was filtered out by the ListGuru mailing software at because binary attachments are not appropriate for mailing lists. If you want a copy of the attachment which was removed, contact the sender directly and ask for it to be sent to you by private E-mail. This warning is inserted into all messages containing binary attachments which have been removed by ListGuru. If you have questions about this message, contact for clarification. --==========2343647794==========-- -- Please see the official ORACLE-L FAQ: -- Author: Steven Lembark INET: Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).

  • application/octet-stream attachment: diskfrie
Received on Thu May 16 2002 - 12:15:46 CDT

Original text of this message