Auto detect the number of CPU's and set worker_processes

justin nginx-forum at
Sat Sep 15 23:55:49 UTC 2012

I am trying to get fancy and have `nginx.conf` auto-detect the number of
CPU's on the server and then set `worker_processes` to that number. Here is
what I have:

    worker_processes $(cat /proc/cpuinfo | grep "processor" | sort -u | wc

Unfortunately, that is throwing an error on nginx start. Is it even possible
to run shell commands from inside nginx configuration files?


Posted at Nginx Forum:,230757,230757#msg-230757

More information about the nginx mailing list