Linux Unix Batch Delete Files

Hi,

Sometimes you may want to delete all trace, log files, audit files completely.

 

 

If any disk or mount pount is nearly full in linux then you will think that What should i delete ?

 

You can find out top directories using following my article

 

https://ittutorial.org/2019/03/08/how-to-find-out-top-directories-and-files-disk-space-in-linux/

 

The answer of above question is mostly log files, trace files, audit files, .xml files and etc…

If you specify logfiles, trace files directory then you can delete all files together like following.

 

–For IBM AIX, Delete all files which extensions are like .trc Under /oracle directory

find /oracle -name "*.trc" -type f -exec rm -f {} \;

 

— For Linux, Delete all files which extensions are like .aud Under /u01 directory

find /u01 -name "*aud" -print | xargs rm -rf

 

You may want to delete files older than 3 days, you can use following query.

find / -name "*.log" -mtime +3 -print | xargs rm -rf

 

You can change extension name and directory name to delete according to your need

 

 

Do you want to learn Linux System Administration for Beginners, then read the following articles.

https://ittutorial.org/linux-administration-tutorial-for-beginners/

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected].-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  [email protected] a mail atabilirsiniz.

2 comments

  1. each time i used to read smaller articles which
    also clear their motive, and that is also happening with
    this article which I am reading now.

  2. I advise against piping find data to xargs rm. If you are not in control of all the filenames (some other user has write access in the relevant places) the wrong files may be removed.

    http://www.zen19351.zen.co.uk/article_series/find_xargs_rm.html

Leave a Reply

Your email address will not be published. Required fields are marked *