Squid - multiple instances of proxy_monitor.sh

  • Hello All,

    Today I did a ps on one our pfSense 1.2.3 boxes and saw 7 instances of proxy_monitor.sh.  We have been experimenting with DHCP on WAN and plugging and unplugging the ethernet cable to test it. It seems that when the DHCP lease expires and an new IP address is assigned to the WAN all the packages get resynced causing the a new instance of proxy_monitor.sh to be spawned.    This happens with both WAN and OPT1 when configured with DHCP.  I haven't explored this much but decided to add the following code to proxy_monitor.sh which causes it to exit if there is already an instance of the process running…

    Not sure if this is happening with 2.0.  In any event there should always only be one copy of proxy_monitor running. The code below prevents multiple instances for whatever reason. It might be a good idea to add this to the code base for unforeseen circumstances that might cause more than once instance of this to run.

    set -e


    is proxy_monitor.sh already running?

    if [ -f "$PROXMONPID" ] ; then
        oldpid=cat "$PROXMONPID"
        isrunning=(ps awux | grep "$oldpid" | grep -v "grep" | awk '{ print $2}')
        if [ -n "$isrunning" ]; then
            echo "$0 already running"

    echo -n $$ > "$PROXMONPID"


    and at the bottom of the file…

    if [ -f "$PROXMONPID" ] ; then
            rm "$PROXMONPID"