Friday, 6 March 2020

Delete old files through scripts

# To delete old files older then 90 days
find /home/scripts/    -mtime +90 -exec rm ( )\;

#To add .old extension to older files from more then 90 days
find /home/scripts/ -mtime +90 -exec mv {} {}.old ( ) \;

#To list all the files older then 90 days

find /home/scripts/ -mtime +90 -exec ls -l ( ) \;

No comments:

Post a Comment