Skip to content

Instantly share code, notes, and snippets.

@djvdorp
Forked from zeuxisoo/restart-php-fpm.sh
Last active July 15, 2024 15:52
Show Gist options
  • Save djvdorp/530a7022ab23534e4400f4b77472b88b to your computer and use it in GitHub Desktop.
Save djvdorp/530a7022ab23534e4400f4b77472b88b to your computer and use it in GitHub Desktop.
Auto Restart PHP-FPM when LoadAvg15 under 1
#/bin/bash
# the load average for the last 1, 5, and 15 minutes. we get the third one:
LOAD=$(awk '{print $3}' /proc/loadavg)
if [ $(echo "$LOAD < 1" | bc) = 1 ]; then
/usr/bin/systemctl restart php-fpm
else
echo "All seems well, moving on"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment