Home » How to free oracle disk space – Automate disk cleanup.

How to free oracle disk space – Automate disk cleanup.

by mn.sobieh

In part one we explained what files Oracle Instance creates and eats our precious disk-space, This article explains how to identify and free oracle server disk space.

Reasons for the server to stop creating new files.

Servers might stop creating new files or adding new files due to multiple reasons:

1. You consumed all available disk space.

in that error, you get the message.

oracle@srv$ touch textfile 
touch: cannot touch ‘textfile’: No space left on device

You can detect file system disk space usage by executing the du command with -h parameter.

2. Your disk quota reached its limit.

oracle@srv$ mkdir tstdir
mkdir: cannot create directory ‘tstdir’: Disk quota exceeded

3. You consumed all allowed Inodes. 

An inode is a data structure used to keep information about a file on your hosting account. The number of inodes indicates the number of files and folders you have. This includes everything on your account, emails, files, folders, anything you store on the server.

 using du command with parameter -i it will show total nodes used and available Inodes for each mounted disk.

oracle@srv$ du -i

What directories need cleaning?

in that clustered environment which consists of two nodes and ASM. The script cleans the following directories

  • ASM Audit trail.
    in ASM home  “create separate ” script to be executed by grid user


  • Database Audit trails.
    in Database home


  • Database trace files.
    in Database home


ADRCI to clean your Oracle disk-space 

After identifying the biggest directories that consume your server disk space. you need three environment variables which are ORACLE_UNIQNAME, ORACLE_SID, ORACLE_BASE

export ORACLE_UNQNAME=cdb1 
export ORACLE_SID=cdb1
export ORACLE_BASE=/u01/app/oracle

Clear Audit and trace files using the Automatic Diagnostic Repository (ADR) tool. adrci located in bin under oracle home. 


Next, list available homes that have logs. 

adrci> show homes
ADR Homes:

Then, set adrci home that the purge command will work in. for example, for cdb1  

set home diag/rdbms/cdb1/cdb1

After that, purge all logs.

adrci> purge -age 60

Finally, repeat this process with each home. in addition, if there are other oracle software installed change the adrci base, then repeat the same process. 

How to free oracle disk-space-04-adrci

Schedule cleaning script.

First, create a cleanup script and put in it the command that will remove all traces and audit files.
oracle@srv$ vi /u01/cleanUP.sh

export ORACLE_UNQNAME=cdb1 
export ORACLE_SID=cdb1 
export ORACLE_BASE=/u01/app/oracle 
find $ORACLE_BASE/admin/$ORACLE_SID/adump -name “*.aud” -mtime +14 -type f -delete 
find $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace -name “*.tr?” -mtime +14 -type f -delete

now you add it to cron scheduler to execute every day at 1AM. Read corn manual for more information  

oracle@srv$ crontab -e 

00 01 * * * find /u01/cleanUP.sh

To conclude,

You may also like

Leave a Comment