#!/bin/bash sed -i "/^ulimit -SHn.*/d" /etc/rc.local echo "ulimit -SHn 102400" >> /etc/rc.local sed -i "/^ulimit -s.*/d" /etc/profile sed -i "/^ulimit -c.*/d" /etc/profile sed -i "/^ulimit -SHn.*/d" /etc/profile cat >> /etc/profile << EOF # # # ulimit -c unlimited ulimit -s unlimited ulimit -SHn 102400 EOF source /etc/profile ulimit -a cat /etc/profile | grep ulimit echo -e " 33[31m hosts ok 33[0m" if [ ! -f "/etc/security/limits.conf.bak" ]; then cp /etc/security/limits.conf /etc/security/limits.conf.bak fi sed -i "/^*.*soft.*nofile/d" /etc/security/limits.conf sed -i "/^*.*hard.*nofile/d" /etc/security/limits.conf sed -i "/^*.*soft.*nproc/d" /etc/security/limits.conf sed -i "/^*.*hard.*nproc/d" /etc/security/limits.conf cat >> /etc/security/limits.conf << EOF # # # # #---------custom----------------------- # * soft nofile 65535 * hard nofile 65535 * soft nproc 65535 * hard nproc 65535 EOF cat /etc/security/limits.conf | grep "^* .*" echo -e " 33[31m limits ok 33[0m" sleep 1
最后使用ulimit -a 可能看着没改变,可以在使用一次 source /etc/profile