All pastes #2126512 Raw Edit

O KZ BEN AAR CUNGU O BR KAAR DEL

public text v1 · immutable
#2126512 ·published 2012-03-09 23:58 UTC
rendered paste body
ps ax | grep squid | awk '{print $5, $1}' | grep "(squid)" | awk '{print $2}' > /home/squid/var/logs/squid.pidthis=$(grep 'Rebuilding' /home/squid/var/logs/cache.log | awk '{print $2}' | awk -F\| '{print $1}' | sort -nr | head -1 | awk -F: '{print $1 * 3600 + $2 * 60 + $3}')go=$(echo 0)if [ "$this" ]; then        echo "it was rebuilding at some point"        that=$(grep 'Completed Validation Procedure' /home/squid/var/logs/cache.log | awk '{print $2}' | awk -F\| '{print $1}' | sort -nr | head -1 | awk -F: '{print $1 * 3600 + $2 * 60 + $3}')        if [ "$that" ]; then                echo "it also completed rebuilding at some point. Last Rebuild time $this, Finished rebuild time $that"                if [ $that -gt $this ]; then                        echo "it finished after it started, everything ok"                        go=$(echo 1)                else                        echo "it finished at some earlier time, it's still rebuilding"                fi        else                echo "it is still rebuilding"        fielse        echo "it is not rebuilding"        go=$(echo 1)fiif [ "$go" ]; then        /home/squid/sbin/squid -k rotate        sleep 30        for i in $( ls /home/squid/var/logs/access.log.? );                do                        src=$i                        thing=$(echo "`date +%s`" )                        stuff=$i.$thing                        mv $src $stuff                done        for i in $( ls /home/squid/var/logs/cache.log.? );                do                        src=$i                        thing=$(echo "`date +%s`" )                        stuff=$i.$thing                        mv $src $stuff                done        find /home/squid/var/logs/* -type f -mtime +6 -exec rm -f {} \;fi