#!/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
时间: 2024-10-08 13:29:51