解除进程限制

This commit is contained in:
spiritlhl 2024-06-20 15:39:05 +08:00 committed by GitHub
parent 55f08169b1
commit cb9788a273
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

42
repair_scripts/unlimit.sh Normal file
View File

@ -0,0 +1,42 @@
#!/bin/bash
#by spiritlhl
#from https://github.com/spiritLHLS/one-click-installation-script
#version: 2024.06.20
# 更新 /etc/security/limits.conf 文件
echo "更新 /etc/security/limits.conf 文件..."
sed -i '/^root soft nofile /d' /etc/security/limits.conf
sed -i '/^root hard nofile /d' /etc/security/limits.conf
sed -i '/^\* soft nofile /d' /etc/security/limits.conf
sed -i '/^\* hard nofile /d' /etc/security/limits.conf
echo "root soft nofile 1000000" >> /etc/security/limits.conf
echo "root hard nofile 1000000" >> /etc/security/limits.conf
echo "* soft nofile 1000000" >> /etc/security/limits.conf
echo "* hard nofile 1000000" >> /etc/security/limits.conf
# 更新 /etc/pam.d/common-session 文件
echo "更新 /etc/pam.d/common-session 文件..."
if ! grep -q "session required pam_limits.so" /etc/pam.d/common-session; then
echo "session required pam_limits.so" >> /etc/pam.d/common-session
fi
# 更新 /etc/pam.d/common-session-noninteractive 文件
echo "更新 /etc/pam.d/common-session-noninteractive 文件..."
if ! grep -q "session required pam_limits.so" /etc/pam.d/common-session-noninteractive; then
echo "session required pam_limits.so" >> /etc/pam.d/common-session-noninteractive
fi
# 更新 /etc/systemd/system.conf 文件
echo "更新 /etc/systemd/system.conf 文件..."
sed -i '/^DefaultLimitNOFILE=/d' /etc/systemd/system.conf
echo "DefaultLimitNOFILE=1000000" >> /etc/systemd/system.conf
# 更新 /etc/systemd/user.conf 文件
echo "更新 /etc/systemd/user.conf 文件..."
sed -i '/^DefaultLimitNOFILE=/d' /etc/systemd/user.conf
echo "DefaultLimitNOFILE=1000000" >> /etc/systemd/user.conf
sleep 1
systemctl daemon-reload
echo "请重启服务器使得修改生效"