Created
October 21, 2014 17:50
-
-
Save modsaid/38734f2ae1e832f267c1 to your computer and use it in GitHub Desktop.
Rename hourly rotated web access logs (access.log.1, access.log.2) to include the timestamp for better management of the times
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
#!/bin/bash | |
# This script is made to rename default rotated access log files from access.log.1, access.log.2 and | |
# so on, to using timestamp instead of auto increment index (to be access.log.2014102009) | |
# | |
# USAGE: | |
# cd LOGS_DIR && ./access-logs-timestamp.sh | |
FILES=access.log* | |
for f in $FILES | |
do | |
newname="access.log.`date -r $f +'%Y%m%d%H'`" | |
echo "renaming $f to $newname" | |
mv $f $newname | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment