-
What Are Oracle Archive Logs?
-
Why Delete Old Archive Logs
-
How to Use RMAN Command Line to Delete Archivelog Older Than 1 Day?
-
How to Automate Oracle RMAN Delete Archivelog Older Than 1 Day?
-
Vinchin Backup & Recovery: Enterprise-Level Protection for Oracle Databases
-
Oracle RMAN Delete Archivelog Older Than 1 Day FAQs
-
Conclusion
A full archive log destination can halt your Oracle database in minutes. For operations administrators, managing Oracle archive logs is not just routine—it’s critical. If old logs pile up unchecked, storage fills fast. This can slow down your system or even cause outages. Wondering how to use Oracle RMAN to delete archivelog older than 1 day? This guide explains every step clearly, from basics to advanced best practices.
What Are Oracle Archive Logs?
Oracle archive logs are copies of redo log files created when your database runs in ARCHIVELOG mode. These logs record every change made in the database. Archive logs are vital for point-in-time recovery and disaster recovery because they let you restore data to any moment before a failure.
Without archive logs, you lose the ability to recover recent transactions if something goes wrong. That’s why most production databases keep ARCHIVELOG mode enabled at all times.
Why Delete Old Archive Logs
Keeping too many archive logs can quickly eat up disk space on your server. When storage fills up, Oracle may stop processing new transactions or fail during backup jobs. Deleting old archive logs that you no longer need helps prevent these problems.
Efficient log management keeps backups quick and recovery smooth. However, never delete logs that might be needed for future restores—always check your backup policies first.
How to Use RMAN Command Line to Delete Archivelog Older Than 1 Day?
The Oracle Recovery Manager (RMAN) is the safest tool for managing archive logs. It ensures both file deletion and catalog cleanup happen together—a must in complex setups like RAC clusters or Data Guard environments.
Before You Begin: Safety Checklist
Before deleting any archive logs with RMAN, take these steps:
1. Confirm your database is running in ARCHIVELOG mode by running
SELECT log_mode FROM v$database;
Only databases in ARCHIVELOG mode generate these files.
2. Make sure you have recent backups of all necessary archive logs by checking
LIST BACKUP OF ARCHIVELOG ALL;
This prevents accidental loss of recoverable data.
3. Review retention policies so you do not remove required files too soon.
4. If using Data Guard or a standby setup, verify which logs have been applied on standby nodes before deleting them from primary storage.
Step-by-Step: Deleting Archive Logs Older Than 1 Day
Here’s how you safely remove old archive logs using RMAN:
1. Open a terminal window and log in as the oracle user.
2. Start RMAN by typing rman target / then pressing Enter.
3. At the RMAN prompt, run this command:
DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-1';
This deletes all archived redo log files whose completion time is more than one day ago—not just those created over a day ago but those fully written before then.
4. Next, update RMAN’s records by running:
CROSSCHECK ARCHIVELOG ALL;
This checks if each archived log listed in the catalog still exists on disk.
5. Clean up expired entries from the catalog with:
DELETE EXPIRED ARCHIVELOG ALL;
This two-step process ensures both physical files and metadata are cleaned up properly—avoiding errors later during backup or restore operations.
Special Note for Data Guard Users
If you use Data Guard standby databases, set an appropriate deletion policy first:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
This tells RMAN not to delete any archived redo log until it has been applied on all standbys—protecting against accidental data loss across sites.
You can confirm which archived redo logs have been deleted or applied on standby by querying:
SELECT dest_id, applied FROM v$archived_log WHERE deletion_status='DELETED';
Always double-check backup requirements before removing any archive log files!
How to Automate Oracle RMAN Delete Archivelog Older Than 1 Day?
Manually cleaning up old archive logs every day isn’t practical for busy environments—automation saves time and reduces risk of human error.
You can automate this process using operating system schedulers like cron on Linux/Unix or Task Scheduler on Windows systems.
Automating With Shell Scripts (Linux/Unix)
First create a shell script—for example /home/oracle/delete_archivelog.sh—with robust logging:
#!/bin/bash
export ORACLE_SID=yourdb
export DATE=$(date '+%Y%m%d_%H%M%S')
LOGFILE="/home/oracle/logs/archivelog_deletion_${DATE}.log"
{
echo "=== Archive Log Deletion Job Started at $(date) ==="
rman target / <<EOF
DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-1';
CROSSCHECK ARCHIVELOG ALL;
DELETE EXPIRED ARCHIVELOG ALL;
EXIT
EOF
echo "=== Job Finished at $(date) ==="
} > "${LOGFILE}" 2>&1Replace yourdb with your actual ORACLE_SID value so it targets the right instance.
Make it executable:
chmod +x /home/oracle/delete_archivelog.sh
Schedule daily execution at midnight via crontab:
0 0 * * * /home/oracle/delete_archivelog.sh
This setup creates timestamped log files under /home/oracle/logs, making it easy to review job history or troubleshoot failures later.
Automating With Batch Files (Windows)
On Windows servers:
1. Create a batch file such as C:\oracle\delete_archivelog.bat containing:
rman target / @C:\oracle\delete_archivelog.rman
2. Prepare an input file named delete_archivelog.rman with these lines:
DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-1'; CROSSCHECK ARCHIVELOG ALL; DELETE EXPIRED ARCHIVELOG ALL; EXIT
3. Use Task Scheduler: Set up a daily task pointing at your batch file so cleanup happens automatically overnight—or whenever suits your maintenance window best!
Vinchin Backup & Recovery: Enterprise-Level Protection for Oracle Databases
For organizations seeking streamlined management of Oracle archivelogs and backups beyond manual scripting, Vinchin Backup & Recovery provides an enterprise-grade solution supporting today’s leading databases—including Oracle, MySQL, SQL Server, MariaDB, PostgreSQL, PostgresPro, and TiDB—with special emphasis here on its robust support for Oracle environments. Key features include incremental backup capabilities tailored for Oracle workloads; comprehensive batch database backup; flexible data retention policies including GFS options; integrity checks; and reliable any-point-in-time recovery—all designed to maximize data safety while minimizing administrative effort through automation and policy-driven controls.
The intuitive web console makes protecting your Oracle environment straightforward:
Step 1: Select the Oracle database to back up;

Step 2: Choose backup storage;

Step 3: Define your backup strategy;

Step 4: Submit the job.

Vinchin Backup & Recovery is trusted globally by enterprises seeking reliable data protection solutions—try its full-featured platform free for 60 days and experience why it consistently earns top ratings worldwide.
Oracle RMAN Delete Archivelog Older Than 1 Day FAQs
Q1: Is it safe to delete archivelogs older than one day if my last full backup was taken yesterday?
A1: Yes—but only if no incremental backups depend on those older archivelogs; always confirm before deleting them!
Q2: How do I preview which archivelogs would be deleted without actually removing them?
A2: Run DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-1' PREVIEW; at the RMAN prompt—it shows candidates without deleting anything yet!
Q3: What should I do if my automated script fails due to permission errors?
A3: Check directory permissions for both source/destination folders then rerun script as an account with sufficient rights.
Conclusion
Deleting old Oracle archivelogs keeps systems healthy—and automating this task saves time while reducing risk of outages due to full disks! Always verify backups first before removal actions begin; for streamlined protection across complex environments try Vinchin’s powerful solutions today with their free trial offer!
Share on: