Skip to content

Instantly share code, notes, and snippets.

@Swop
Created July 17, 2013 23:17
Show Gist options
  • Select an option

  • Save Swop/6025415 to your computer and use it in GitHub Desktop.

Select an option

Save Swop/6025415 to your computer and use it in GitHub Desktop.
Simple rotate log script
#!/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