The proxy fails once. Later requests succeed, yet the watchdog keeps announcing another failure. Check whether the script remembered yesterday's exit status.

This pattern only updates the variable when curl fails:

status=0
# Repeated inside a loop:
curl ... || status=$?

After the first nonzero result, a successful iteration leaves status untouched. It does not become zero merely because curl succeeded.

Branch on the current command instead:

if curl --proxy socks5h://127.0.0.1:1080 --noproxy '' \
    --fail --silent --show-error --connect-timeout 3 --max-time 10 \
    https://health.example/ >/dev/null; then
    echo "check succeeded"
else
    echo "check failed"
fi

The address and timings are illustrative. This removes the stale variable; it does not decide what recovery action is appropriate.

Keep the observation narrow. The request depends on the proxy, onward route, destination, TLS verification, and HTTP outcome. A target outage can fail it while the SOCKS service is healthy. An unexpected HTTP 200 page can also pass a status-only check without supplying the expected content.

Choose a controlled response contract and retain the failure stage. Restarting the proxy on every nonzero curl result can disrupt healthy sessions while leaving the real destination problem untouched.

Tënë sô zo