How to find ulimit (Max Open FIles Limit) for Nginx on Ubuntu  

  RSS

Tharindu
(@tharindu)
Admin
Joined: 5 years ago
Posts: 212
14/06/2019 9:30 am  

Finding ulimit (Max open files) for nginx user is important when optimizing nginx configuration. Specially when setting worker_rlimit_nofile directive and worker_connections directive. The simple commands to check this limits are as follows.

ulimit -Hn
ulimit -Sn

These commands only work if you can login to the user account. If you execute these commands as root user, you get the values for root user. And to find the limits for nginx user, you need to be logged in to that account (www-data or nginx). But the problem is, we can't login to nginx user account. Because it has the nologin shell. Instead of trying to change the shell for www-data (or nginx), you can use following method to check the ulimit for www-data.

Get the PID for www-data,

ps -u www-data

Note the PID value for nginx. And then execute following command with term PID replaced with actual PID,

grep 'open files' /proc/PID/limits

It'll return max open file limit for nginx.

This topic was modified 1 month ago 4 times by Tharindu

Become a vpsfix.com affiliate and earn up to 10% commissions from your referrals


Quote
Share:
Back to top button
Close
  
Working

Please Login or Register