第一步、
vim /etc/security/limits.conf
打开limits文件
在最后添加
- soft nofile 100000
- hard nofile 100000
root soft nofile 100000
root hard nofile 100000 - soft core unlimited
- hard core unlimited
root soft core unlimited
root hard core unlimited
如果只设置第一步,就无法再crontab里生效。
所以还要设置第二步、
vim /etc/systemd/system.conf
打开系统配置文件
DefaultLimitNOFILE=1000000
修改此参数
接着重启服务器
接着重启服务器
接着重启服务器
重启后
cat /proc/进程ID(PID)/limits
看到 Max open files 变了就代表成功了。