1. 程式人生 > >too many open files問題解決辦法

too many open files問題解決辦法

今天用程式碼往liunx中寫檔案,檔案很多程式碼執行一會就日誌上就報錯:“too many open files”。結果找了半天才解決這個問題,現在給大家分享一下。

首先用“ulimit -a”命令看看linux的open files值是多少,結果一隻有1024,不夠用的。然後修改linux的配置檔案,修改/etc/security/limits.conf

* hard nofile 65535

* soft nofile 65535

然後重啟虛擬機器後在用“ulimit -a”命令檢視open files值變為了65535,我的問題得到解決。當然還有很多原因導致too many open files錯誤;我的只是其中一種原因的解決辦法。希望對您有所幫助。