Welcome to Nik Maslov`s blog
« MAC address from OBP promptHow to migrate from dying system disk to new one in Solaris »

Squid log rotation with timestamp

Permalink 11/06/09 15:55, by Nik Maslov, Categories: Background , Tags: squid rotate logs 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 »

6 comments

Comment from: andrei noga [Visitor]
use /bin/sh instead of bash
11/06/09 @ 18:42
Comment from: Nik Maslov [Member] Email · http://www.nikmaslov.com
yes, one could use that...

if be more precise, and old-school - you`d probably find useful to use
#!/bin/ksh
11/07/09 @ 18:35
Awesome post, you have alot of knowledge on the topic, http://www.rapidsloth.com/30-Abstract-Landscapes-Wallpapers.html review similar ideas and tell their opinions.
04/11/10 @ 11:25
Comment from: Envirow [Visitor] · http://www.envirowhomes.com
woww.. great article :) thanks for sharing buddy.. keep posting
07/06/10 @ 03:00
Comment from: apinfrastructure [Visitor] · http://www.apinfrastructure.com
woww.. great article.. allow me to bookmark it buddy :) thanks for sharing, keep posting :D
07/09/10 @ 23:41
dfytyuty
08/24/10 @ 06:19

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)

Search

XML Feeds

StatCounter

powered by b2evolution