Ask the Expert

Explanation of code for deleting audit files

Brian Peasland's tip "Do you have audit files?" of 24 May 2001 used the following code to delete the audit files that were over 30 days old:

    Requires Free Membership to View

find $ORACLE_HOME/rdbms/audit/*.aud -mtime +30 -exec rm -f {} ;

My version of HP-UX can work with this up to and including the rm to remove the files. What is the -f switch, and what does it do? What do the {} and ; indicate, and what do they do? Thanks, Steve


Steve,
I hope that the tip is serving you well. Here I offer up some further explanation. According to the manual (man rm), the -f switch means:


     -f        Do not prompt for confirmation. Do not write diag-
               nostic  messages  or modify the exit status in the
               case  of  non-existent  operands.   Any   previous
               occurrences of the -i option will be ignored.

The easiest way to think of this is that 'f' stands for "force". It means to ignore the confirmation prompt and force the delete no matter what.

The results of the find command are passed as arguments to the spawned command, via the -exec switch. In this case, the spawned command is the remove (rm) command. We use the braces, '{}' as a place holder for the arguments to the rm command. I'm not sure why the '\;' is there other than it needs to be. It is a requirement of the -exec switch. Again checking the manual (man find), we can find the following:


     -exec command
               True if the executed command returns a zero  value
               as  exit status.  The end of command must be punc-
               tuated by an escaped semicolon.  A  command  argu-
               ment {} is replaced by the current path name.

The manual talks about the braces as a place holder for the results of the find command. Furthermore, the manual says "The end of command must be punctuated by an escaped semicolon." I'm not a Unix guru, so I don't know exactly why it is required, but the manual says that it is required.

If you are having problems with this on your HP-UX platform, then I do have another solution written in Perl. I know that this command works on Sun Solaris and SG Irix. Unfortunately, I do not have the same functionality on a Windows platform. So I had to write a Perl script which performs the same function. If you need a copy, please ask!

For More Information


This was first published in June 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: