Commit 394aa095 authored by Antoine Durand-Gasselin's avatar Antoine Durand-Gasselin
Browse files

[squid_logrotate.sh] le script effectue aussi du nettoyage

darcs-hash:20090312104429-bd074-9c4434c55370df2913991131735deb38ca42177e.gz
parent 264f35fc
#!/bin/sh
#!/bin/zsh
umask 0177
logs_src=/var/log/squid
logs_dst="/home/squid/`hostname`/logs"
dernier_fichier=$logs_src/$(ls -tr "$logs_src" | grep access.log | head -1)
while ( ls -tr "$logs_src" | grep -E 'access\.log\.[0-9]+\..z2?' ); do
dernier_fichier=$logs_src/$(ls -tr "$logs_src" | grep -E 'access\.log\.[0-9]+\..z2?' | head -1)
timestamp=$(bzcat "$dernier_fichier" | head -1 | awk '{print $1}')
date=$(date -d "1970-01-01 $timestamp sec" +"%Y-%m-%d")
install -o root -g root -m 0400 -p "$dernier_fichier" "$logs_dst/access.log.$date.bz2"
echo mv "$dernier_fichier" "$logs_dst/access.log.$date.bz2"
echo chown root:root "$logs_dst/access.log.$date.bz2"
echo chmod 400 "$logs_dst/access.log.$date.bz2"
mv "$dernier_fichier" "$logs_dst/access.log.$date.bz2"
chown root:root "$logs_dst/access.log.$date.bz2"
chmod 400 "$logs_dst/access.log.$date.bz2"
done
#find "$logs_dst" -mtime +365 -delete
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment