Created
July 17, 2013 23:17
-
-
Save Swop/6025415 to your computer and use it in GitHub Desktop.
Simple rotate log script
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
| #!/bin/bash | |
| # Usage: rotate.sh filename | |
| logfile=$1 | |
| if [ ! -f $logfile ]; then | |
| echo "log file not found $logfile" | |
| exit 1 | |
| fi | |
| timestamp=`date +%Y%m%d` | |
| newlogfile=$logfile.$timestamp | |
| cp $logfile $newlogfile | |
| cat /dev/null > $logfile | |
| bzip2 -f -9 $newlogfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment