Reputation: 1073
It's easy enough to do it with tar:
date=`date +%F-%T`;find /var/log/nginx -name "access.log" -mtime -1 -type f -print | xargs -0 tar czvf /tmp/$date-access.tar.gz
.
$ ls /tmp
2019-05-03-11:25:49-access.tar.gz
How do I do this with gzip?
Upvotes: 0
Views: 1172
Reputation: 92854
find
+ bash
+ gzip
solution:
$ d=$(date +%F-%T)
$ find /var/log/nginx -name "access.log" -mtime -1 -type f \
-exec bash -c 'gzip -c "$2" > "/tmp/$1-access.gz"' _ $d {} \;
Upvotes: 2