Skip to content

Instantly share code, notes, and snippets.

@rojenzaman
Created Jun 16, 2021
Embed
What would you like to do?
Compress NGINX logs as ZSTANDART.
#!/bin/bash
# Run with find command:
#
# find /var/log/nginx -name "*.log" -exec /usr/bin/log2zst "{}" \;
#
if [ "$#" -lt 1 ]; then
echo "Usage: `basename $0` <filename>"
exit 1
fi
zstd --rm -c "$1" > "$1-`date +%Y%m%d`.zst"
touch $1
@rojenzaman

This comment has been minimized.

Copy link
Owner Author

@rojenzaman rojenzaman commented Jun 20, 2021

log2zst.service

[Unit]
Description=Compress NGINX logs as ZSTANDART.
Wants=log2zst.timer

[Service]
User=root
CPUWeight=40
CPUQuota=40%
IOWeight=40
ExecStart=/usr/bin/find /var/log/nginx -name "*.log" -exec /usr/bin/log2zst "{}" \;

[Install]
WantedBy=multi-user.target

log2zst.timer

[Unit]
Description=Compress NGINX logs as ZSTANDART.
Wants=log2zst.service

[Timer]
Unit=log2zst.service
OnCalendar=weekly

[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment