Last active
June 16, 2016 09:12
-
-
Save Colorfulstan/52a75df8aeed4379d41d5386a088e86a to your computer and use it in GitHub Desktop.
Create tar for logs (or files in general) with previous month in filename on Ubuntu / Linux / Unix
And delete those files afterwards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATESTAMP="$(date -d "1 month ago" +"%Y-%m")" | |
FILESPEC="*${DATESTAMP}*.log" | |
tar cvzf "${DATESTAMP}.tar.gz" $FILESPEC && rm ${FILESPEC} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment