Sunday 17 April 2016

How to Delete LOGFILE from older date in Linux



In Oracle database there are some files which reguarly create day by day such as trace files, log files, archivelog files & Exported dump files.

In this article i will show how to remove above files as batch job.

This Task is the Housekeeping work performed by a DBA.

  Ø  Linux platform

We can use find command for this purpose.

for example:
 $ find $TRACEFILE/*.trc -mtime +7 -exec rm {} \;  

above script remove all .trc files which older than 7 days.

Schedule: Through crontab utility schedule above script.


   Ø  Windows platform

We can use FORFILES.exe for this purpose


for example:
 D:\FORFILES.EXE /P D:\archive_dump_files -s /M *.* /D -5 /C "cmd /c del @FILE echo @FILE"  

D:\FORFILES.EXE /P D:\archive_dump_files -s /M *.* /D -5 /C "cmd /c del @FILE echo @FILE"

In above example files deleted older than 5 days from "archive_dump_files" location.


Schedule: We can use WINDOWS SCHEDULER TASK for this purpose.

No comments:

Post a Comment