Squid and SquidGuard crash problem when i use script



  • Hi

    I prepared 1 script for squid cache clean, when i use this script on the command line it works very well.
    But when i add cron job this script squid and squidguard didnt work very well and system logs says you must use squid -z command and make squid cache. and i looked /var/squid/cache folder it is empty. How can i use with crontab this script. Thanks

    SquidCacheClean.sh

    #Created By Volkan Vural
    #This script using for Squid Cache Folder Cleaning for crontab
    #e-mail=aytvolkan@hotmail.com
    #Publish Date = 16.09.2011

    ps -f | grep "proxy_monitor.sh" | awk '{print $1}' | xargs kill -9
    /usr/local/etc/rc.d/squid.sh stop
    rm -rf /var/squid/cache/
    mkdir -p /var/squid/cache/
    chown proxy:proxy /var/squid/cache/
    chmod 777 /var/squid/cache/
    squid -z
    /usr/local/etc/rc.d/squid.sh start
    #Proxy Monitor Shell Starting
    nohup sh /usr/local/etc/rc.d/proxy_monitor.sh start &

    Volkan



  • Do you clean cache dir whilst squid/squidguard are active and running?
    I found after updating to "release", that squid / squidguard get restarted after a little while after you disable (stop) both using the web GUI.
    I needed to clean the cache by hand, but only had a brief moment to "rm -rf /var/squid/cache/" the cache directory before squid would become active again.
    I checked using "ps ax | grep squid" to see if squid was really inactive before the removal of the cache directory.
    In my case it would not remove the dir when squid was using it.

    Maybe in your case the dir is partly removed before squid auto restarts again or at least attempts to restart and fails in the process.
    You should pipe the output from the script commands to a log-file to see where it fails, at "rm" part or at "squid -z" part of the script.



  • Hi

    ps -f | grep "proxy_monitor.sh" | awk '{print $1}' | xargs kill -9

    This command is stopping autorestart squid and squidguard. i had tested.


Log in to reply