Hi Guys,
Delete files older than 30 days
++++++
find . -mtime +30 -exec rm {} \;
++++++
1. Save the deleted files to a log file
++++++
find /home/a -mtime +5 -exec ls -l {} \; > mylogfile.log
++++++
This way, you’ll get a line at top with the date the line is executed (also a line at the bottom).
The last two semicolons are necessary, one is for find and one for bash.
2. modified
Find and delete files modified in the last 30 minutes
++++++
find /tmp/ -type f -mmin 30 -exec rm {} \;
++++++
mtime = days
mmin = minutes
3. force
force delete temp files older then 30 days
++++++
find /tmp -mtime +30 -exec rm -f {} \;
++++++
4. move the files
move files older than 30 days to an archive folder – and preserve path strcuture
++++++
find /tmp -mtime +30 -exec mv -t {} /archive/directory/ \;
++++++
mv -t: ensure directory structure is preserved
Thank you for checking this