Created
February 18, 2021 14:23
-
-
Save mattantonelli/3ff95b66e4d1afd54b7ecc3c76b89925 to your computer and use it in GitHub Desktop.
Archive a logfile with a timestamped filename and gzip it
This file contains hidden or 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
| #!/usr/bin/env sh | |
| # | |
| # Purpose: | |
| # Archive a logfile with a timestamped filename and gzip it | |
| # | |
| # Configuration: | |
| # 1. Set the input and output paths below | |
| # 2. Schedule a cron to execute this script | |
| input=/my/log/alerts.log | |
| output=/my/log/backup/alerts_$(date "+%Y%m%d").log | |
| mv $input $output | |
| gzip $output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment