Skip to content

Instantly share code, notes, and snippets.

@michabbb
Last active January 18, 2018 15:44
Show Gist options
  • Save michabbb/72a0daf169e2047eccc4dc899c6e0621 to your computer and use it in GitHub Desktop.
Save michabbb/72a0daf169e2047eccc4dc899c6e0621 to your computer and use it in GitHub Desktop.
Compress Files from Last Day and Remove after Compression (file format like YYYYMMDD....)
#!/bin/bash
DATE=`date +%Y%m%d -d "1 day ago"`
echo $DATE
cd /var/log/xxxxx
find . -maxdepth 1 -name "$DATE*.bz2" -type f -print0| tar cjfv /var/log/xxxxx/byday/xxx.$DATE.tar.bz2 --remove-files --null -T -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment