Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Someone
Friday, December 28th, 2007 at 10:14:02pm MST 

  1. ps ax | grep squid | awk '{print $5, $1}' | grep "(squid)" | awk '{print $2}' > /home/squid/var/logs/squid.pid
  2.  
  3. this=$(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}')
  4.  
  5. go=$(echo 0)
  6. if [ "$this" ]; then
  7.         echo "it was rebuilding at some point"
  8.         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}')
  9.         if [ "$that" ]; then
  10.                 echo "it also completed rebuilding at some point. Last Rebuild time $this, Finished rebuild time $that"
  11.                 if [ $that -gt $this ]; then
  12.                         echo "it finished after it started, everything ok"
  13.                         go=$(echo 1)
  14.                 else
  15.                         echo "it finished at some earlier time, it's still rebuilding"
  16.                 fi
  17.         else
  18.                 echo "it is still rebuilding"
  19.         fi
  20. else
  21.         echo "it is not rebuilding"
  22.         go=$(echo 1)
  23. fi
  24.  
  25. if [ "$go" ]; then
  26.         /home/squid/sbin/squid -k rotate
  27.         sleep 30
  28.  
  29.         for i in $( ls /home/squid/var/logs/access.log.? );
  30.                 do
  31.                         src=$i
  32.                         thing=$(echo "`date +%s`" )
  33.                         stuff=$i.$thing
  34.                         mv $src $stuff
  35.                 done
  36.  
  37.         for i in $( ls /home/squid/var/logs/cache.log.? );
  38.                 do
  39.                         src=$i
  40.                         thing=$(echo "`date +%s`" )
  41.                         stuff=$i.$thing
  42.                         mv $src $stuff
  43.                 done
  44.  
  45.         find /home/squid/var/logs/* -type f -mtime +6 -exec rm -f {} \;
  46. fi

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
fantasy-obligation