Skip to content

Instantly share code, notes, and snippets.

@mattantonelli
Created February 18, 2021 14:23
Show Gist options
  • Select an option

  • Save mattantonelli/3ff95b66e4d1afd54b7ecc3c76b89925 to your computer and use it in GitHub Desktop.

Select an option

Save mattantonelli/3ff95b66e4d1afd54b7ecc3c76b89925 to your computer and use it in GitHub Desktop.
Archive a logfile with a timestamped filename and gzip it
#!/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