If you would like to delete files whose name ends with "batch.log" older than 30 days, Use the following command.
If you would like to archive files whose name ends with "batch.log" older than 30 days, Use the following command.
The archived file will have timestamp at the end of the filename.
find /var/log/ -name "*batch.log" -mtime +30 -type -f -delete
If you would like to archive files whose name ends with "batch.log" older than 30 days, Use the following command.
The archived file will have timestamp at the end of the filename.
find /var/log/ -name "*batch.log" -mtime +30 -type -f -pront0 | tar -czvf /var/log/batch.log.tar.gz.`date +\%Y%m%d%H%M%S` -T - --null --remove-files
コメント