Issue
I am using the following command to delete the files that are older than 10 days, but I also want to store(log) the list of files that are being deleted using the below command.
find ./path/delete -type f -name '*' -mtime +10 -exec rm {} \;
Solution
If you create a file to log to (touch ./path/to/logfile
), just add another -exec
to your command. Below is a very basic example, but you can add to it:
find ./path/delete -type f -name '*' -mtime +10 -exec rm {} \; -exec echo {} >> ./path/to/logfile \;
Answered By - ifiht Answer Checked By - Dawn Plyler (WPSolving Volunteer)