I want to delete logs which was greater than 100 mb and it should not return or delete current >month logs
CodePudding user response:
Using (GNU) find & date:
find /path -type f -size 100M -mtime $(date --date=yesterday %d) -delete
where /path is where your logs are located. -mtime $(date --date=yesterday %d) means any files last modified more than day of month as of yesterday.
Make sure you test this before you use it, say, by using -ls to print the files instead of deleting them, or prompt before deleting each file with -exec rm -i {} \;.
CodePudding user response:
With find you can use age and size filters and then RM.
find /path/to/files -mtime 30 -size 100M -exec rm {}
I haven't tested it
