| « MAC address from OBP prompt | How to migrate from dying system disk to new one in Solaris » |
Squid log rotation with timestamp
I had a task on implementing the Squid log rotation, but with timestamps. System was on Solaris - but logadm wasn`t the chosen weapon for this task, and we moved to the squid internal capabilities on logs rotation. Only task was to add the timestamp, which also was done.
I hope, someone will find this useful.
- rotatelogs.sh- will force the Squid to rotate logs, timestamp them
#!/bin/bash
# this script rotates squid logs hourly and renames with a timestamp
/usr/local/squid/sbin/squid -k rotate
sleep 10
mv /var/log/squid/access.log.0 /var/log/squid/access.${NOW:=$(date +"%m-%d-%Y_%H_%M")}.log
mv /var/log/squid/cache.log.0 /var/log/squid/cache.${NOW:=$(date +"%m-%d-%Y_%H_%M")}.log
chmod +r /var/log/squid/*
6 comments
if be more precise, and old-school - you`d probably find useful to use
#!/bin/ksh