Forked from israelshirk/normalize_php_fpm_affinity.cron
Last active
September 17, 2015 18:48
Normalize PHP-FPM CPU affinityAssumes 8 processors, #0 assigned to kernel+nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* * * * * root /usr/local/bin/normalize_cpu_affinity.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Normalize PHP-FPM CPU affinity | |
CPU=$((`grep -c processor /proc/cpuinfo` -1)) | |
# PHP-FPM | |
for i in `ps auxw | grep php-fpm | grep -v grep | awk ' { print $2; } '`; do echo $i; taskset -pc 1-$CPU $i; done | |
# Nginx | |
for i in `ps auxw | grep nginx | grep -v grep | awk ' { print $2; } '`; do echo $i; taskset -pc 0 $i; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment