IT Tutorial

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/

 706 views last month,  2 views today

Exit mobile version