Setting the nofile limit in upstart

While working on a Java project that executes multiple sub processes, I found it necessary to increase to the file descriptor limit. By default, processes spawned in Ubuntu had a limit of 1024 open files, but changing that limit via ulimit or by /etc/security/limits.conf had no effect. I discovered that changes in /etc/security/limits.conf (and subsequently /etc/pam.d/common-session ) are only applied to process spawned by a login shell. Programs that launch on startup via “upstart” do not get these limits applied to them. Thankfully, upstart provides the limit stanza that allows you to modify some of these parameters, including the maximum number of open files. To see the limits on process, grab its PID, and cat /proc/<<PID>>/limits

The following is an example of increase the maximum number of open files to 4096 for a given upstart job:

limit nofile 4096 4096

You can checkout the full set of limit options at:

Note: Some of these limits (if not all) are transferred to any children that are forked by the parent

Check out upstart at:

6 thoughts on “Setting the nofile limit in upstart

  1. Thanks very much for this. I spent several hours trying to figure out why I was hitting these limits even though every last setting had been adjusted to allow for more open FDs (or so I thought).

Leave a Reply

Your email address will not be published. Required fields are marked *