Linux 修改最大连接数脚本

#!/bin/bash
fileMax=$(grep "fs.file-max" /etc/sysctl.conf | wc -l)
if [ $fileMax -eq 1 ];then
sed -i '/fs.file-max/c\fs.file-max = 70000' /etc/sysctl.conf
else
sed -i '$a\fs.file-max = 70000' /etc/sysctl.conf
fi

 

nofileMax=$(grep "soft nofile" /etc/security/limits.conf | wc -l)
if [ $nofileMax -eq 1 ];then
sed -i '/soft nofile/c\* soft nofile 10000' /etc/security/limits.conf
else
sed -i '$a\* soft nofile 10000' /etc/security/limits.conf
fi

hdfileMax=$(grep "hard nofile" /etc/security/limits.conf | wc -l)
if [ $hdfileMax -eq 1 ];then
sed -i '/hard nofile/c\* hard nofile 30000' /etc/security/limits.conf
else
sed -i '$a\* hard nofile 30000' /etc/security/limits.conf
fi

sysctl -p

posted on 2017-06-21 16:19  天涯飞鸿  阅读(490)  评论(0编辑  收藏  举报

导航