Linux/Unix shell scripts clear archive log files for DEV and UAT environments, sometimes the database needs to be in archive mode, but it does not need to be backed up. Therefore, the constant increase in archive archiving logs results in a large amount of disk space consumption. In this case, you can use a shell script to automatically clear these archived logs at regular intervals. This article provides a script to clear archived logs. 1. Clear the shell script for archiving logs [python] robin @ SZDB :~ /Dba_scripts/custom/bin> more remove_arch_dump.sh #! /Bin/bash # objects + # FileName: remove_arch_dump.sh | # Desc: | # Remove old archived log and data pump file | # Usage: | #. /remove_arch_dump.sh | # response + filename =/etc/oratab cat $ filename | while read LINE do case $ LINE in \ # *); # comment-line in oratab *) ORACLE_SID = 'echo $ LINE | awk-F: '{Print $1}'-'echo $ ORACLE_SID # --------------------------------- # define archived log directory # export dir =/u02/database/$ ORACLE_SID/archive/echo $ dir filelist = 'ls -t $ dir 'echo $ filelist # delimiter # start to remove archived log and keep last 2 archived log #---------------------------------------------------- ------ Count = 0 for filename in $ filelist do echo $ filename count = $ ($ count + 1) if [$ count-gt 2]; then echo $ count rm-vrf $ dir $ filename fi done ls-tr $ dir # folder # define data pump dump directory # ------------------------------ dir =/u02/database/$ ORACLE_SID/BNR/ dump/echo $ dir filelist = 'LS-t $ dir' echo $ filelist #------------------------------------------------ --------- # Start to remove data pump file and keep last 5 dump file # defaults count = 0 for filename in $ filelist do echo $ filename count = $ ($ count + 1 )) if [$ count-gt 5]; then echo $ count rm-vrf $ dir $ filename fi done ls-tr $ dir ;; esac done exit 2. Script description a. This script reads the database SID defined in oratab through an external loop to find the archive Log Path of the corresponding database and the datapump dump path. B. A for loop is used to clear archived logs and keep the last two archived log files. C. The next for loop is used to clear the dump file exported under the corresponding dump (Oracle datapump) directory under the current SID. D. The last five files in the dump directory are retained. You can modify the number of recent files that are retained (dump 5 or archive log 2. E. If you do not need to clear the dump path, comment out the dump part. F. Deploy it to crontab as needed.