增加 ulimit 打开文件数和最大程序数

增加 ulimit 打开文件数和最大程序数

我正在一台测试机器上工作,我想增加 macOS Sierra 中 ulimit 的最大打开文件数和最大程序数。

我运行了sudo ulimit -n 100000 120000sudo ulimit -u 10000 12000没有显示任何错误。但是当我运行时,ulimit -a什么都没有改变。

我应该怎么办?


$ launchctl 限制

cpu         unlimited      unlimited      
filesize    unlimited      unlimited      
data        unlimited      unlimited      
stack       8388608        67104768       
core        0              unlimited      
rss         unlimited      unlimited      
memlock     unlimited      unlimited      
maxproc     1064           1064           
maxfiles    1000000        1000000   

$ ulimit -a

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 10000
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1064
virtual memory          (kbytes, -v) unlimited

$ csrutil 状态

System Integrity Protection status: disabled.

/etc/launchd.conf chmod:644 chown root:wheel

limit maxfiles 1000000 1000000
limit maxproc 1000000 1000000

/库/LaunchDaemons/limit.maxfiles.plist chmod:644 chown root:wheel

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
        "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>limit.maxfiles</string>
    <key>ProgramArguments</key>
    <array>
      <string>launchctl</string>
      <string>limit</string>
      <string>maxfiles</string>
      <string>1000000</string>
      <string>1000000</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceIPC</key>
    <false/>
  </dict>
</plist>

/库/LaunchDaemons/limit.maxproc.plist chmod:644 chown root:wheel

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
    <dict>
      <key>Label</key>
        <string>limit.maxproc</string>
      <key>ProgramArguments</key>
        <array>
          <string>launchctl</string>
          <string>limit</string>
          <string>maxproc</string>
          <string>1000000</string>
          <string>1000000</string>
        </array>
      <key>RunAtLoad</key>
        <true />
      <key>ServiceIPC</key>
        <false />
    </dict>
  </plist>

相关内容