Today I landed in a system that had a full filesystem, in this case because there was no maintenance of audit files or directly this holding the process that does this work. The purpose of this is to show a simple way to delete the files. Of course, there are many, as can be found and tell you to delete the files that meet the search criteria.
First of all count the files to delete and create a file with the name of all thems
grid12@moti1./app/oracle/grid/rdbms/audit $ ls -rlt | wc -l
grid12@moti1./app/oracle/grid/rdbms/audit $ time ls > report.txt
Below I show a little shell script (bash shell like shebang) that read line by line and perform a rm in each file
while IFS='' read -r line || [[ -n "$line" ]]; do
done < "$1"
Now, set execute permissions and run the script;
grid12@moti1./app/oracle/grid/rdbms/audit $ chmod 700 delete.sh
grid12@moti1./app/oracle/grid/rdbms/audit $ time delete.sh report.txt
In this case, delete about 170.000 files takes 12 minutes, maybe a little slow.
If we analyze the times, the total was twelve minutes from the start until the end. The user and sys fields are CPU time. The user part corresponds to our process and the system part represents the kernel time.
total cpu = 0m35.63s + 2m4.13s = 2m39.76s
if we subtract this total time from cpu of total time of execution of the process
12m20.47s – 2m39.76s = 9m40.71s
These 9m40.71s, although we would have to trace it or see the consumptions (using for example IOCTL) and since we are working with files, that time goes on disk.
Remark that in this setup the temporary file contains the file list to delete is dropped. However delete.sh file is not dropped. I usally drop it like housekeeping policy.
HTH – Antonio NAVARRO