Working with squid access files and the timestamp

I’m not a big fan of perl (just a personal preference) and I always look for ways that I can minimize its use.

To normalize the timestamp field most people pipe to this and it works quite well for them

|perl -p -e ‘s/^([0-9]*)/”[“.localtime($1).”]”/e’

I’m a big fan of awk and whenever possible I like to use it exclusively so now instead of piping to the above perl statement we can now use awk like this

| awk ‘{timestamp=strftime(“%D”,$1); $1=””; print timestamp$0}’

I use capital D for the format being an American.Yes I know its not internationally compatible, for available time formats you can look here http://www.gnu.org/software/gawk/manual/html_node/Time-Functions.html

 

Adding static routes in FreeBSD

Adding routes is easy but doesn’t survive reboots. In order to make a route static or persistent we add an entry to the /etc/rc.conf file

This
route add 192.168.1.0/24 192.168.3.1

becomes this in /etc/rc.conf
static_routes=”net1″
net1=”-net 192.1681.0/24 192.168.3.1

or if you have multiple routes they are space delimited like this
static_routes=”net1 net2″
route_net1=”-net  192.1681.0/24 192.168.3.1″
route_net2=”-net  192.1682.0/24 192.168.3.1″