Skip to content

Instantly share code, notes, and snippets.

@ilyaevseev
Created April 14, 2018 07:34
Show Gist options
  • Save ilyaevseev/c0f364b99f8701c151b9a4b38e563b10 to your computer and use it in GitHub Desktop.
Save ilyaevseev/c0f364b99f8701c151b9a4b38e563b10 to your computer and use it in GitHub Desktop.
Check that Squid is crashed and restart it.
#!/bin/sh
Logger() { level="$1"; shift; logger -t "${0##*/}" -p "user.$level" -- "$@"; return 0; }
test -f "/var/run/squid/squid.pid" || exit 0
pgrep -F "/var/run/squid/squid.pid" | grep -q '' &&
Logger info "Squid OK" &&
exit 0
Logger err "Squid seems dead, try to restart..."
/usr/local/etc/rc.d/squid restart
test -f "/var/run/squid/squid.pid" &&
pgrep -F "/var/run/squid/squid.pid" | grep -q '' &&
Logger notice "Squid restarted." ||
Logger err "Squid restart failed."
## END ##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment