Linux系統中最大檔案、程序開啟數修改
阿新 • • 發佈:2020-12-16
最大檔案開啟數修改:
#!/bin/bash a=`cat /etc/security/limits.conf|grep "nofile"|tail -n 2` b=`echo $a |grep ^#` if [ -f /etc/security/limits.conf ]; then cp /etc/security/limits.conf /etc/security/limits.conf.bak if [ ! -z "$a" ];then if [ -z "$b" ];then c=`cat /etc/security/limits.conf|grep "nofile"|tail -n 1|awk -F " " '{print $4}'` sed -i "s/soft nofile $c/soft nofile 65535/g" /etc/security/limits.conf sed -i "s/hard nofile $c/hard nofile 65535/g" /etc/security/limits.conf else echo "* soft nofile 65535" >> /etc/security/limits.conf echo "* hard nofile 65535" >> /etc/security/limits.conf fi else echo "* soft nofile 65535" >> /etc/security/limits.conf echo "* hard nofile 65535" >> /etc/security/limits.conf fi fi
最大程序開啟數修改:
#!/bin/bash a=`cat /etc/security/limits.conf|grep "nproc"|tail -n 2` b=`echo $a |grep ^#` if [ -f /etc/security/limits.conf ]; then cp /etc/security/limits.conf /etc/security/limits.conf.bak if [ ! -z "$a" ];then if [ -z "$b" ];then c=`cat /etc/security/limits.conf|grep "nproc"|tail -n 1|awk -F " " '{print $4}'` sed -i "s/soft nproc $c/soft nproc 65535/g" /etc/security/limits.conf sed -i "s/hard nproc $c/hard nproc 65535/g" /etc/security/limits.conf else echo "* soft nproc 65535" >> /etc/security/limits.conf echo "* hard nproc 65535" >> /etc/security/limits.conf fi else echo "* soft nproc 65535" >> /etc/security/limits.conf echo "* hard nproc 65535" >> /etc/security/limits.conf fi fi