How do you set a soft limit for maxopenfiles in Yosemite?

I installed Yosemite last night, and now it's ignoring my settings in my /etc/launchd.conf file:

$ cat /etc/launchd.conf
limit maxfiles 32768 65536

$ launchctl limit maxfiles
    maxfiles    256            unlimited
up vote 3 down vote accepted

It looks like Apple removed support for /etc/launchd.conf for security reasons. It no longer exists on a clean Yosemite install.

From the man launchctl file:

launchctl no longer has an interactive mode, nor does it accept commands from stdin. The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations.

I created a /etc/sysctl.conf file with the following contents:

kern.maxfiles=100000

If I run sysctl kern.maxfiles after restarting it does show the new value there.

Suggested method for most versions of macOS is to create the property list file (.pfile) of a user agent in a LaunchAgents directory.

This can be created by the following command:

sudo /usr/libexec/PlistBuddy /Library/LaunchAgents/com.launchd.maxfiles.plist -c "add Label string com.launchd.maxfiles" -c "add ProgramArguments array" -c "add ProgramArguments: string launchctl" -c "add ProgramArguments: string limit" -c "add ProgramArguments: string maxfiles" -c "add ProgramArguments: string 10240" -c "add ProgramArguments: string unlimited" -c "add RunAtLoad bool true"

Documentation page: Creating Launch Daemons and Agents.

Related: How to persistently control maximum system resource consumption on Mac?

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.