Advertisement
vhuezo

Establecer ulimit-n para archivos abiertos

Oct 3rd, 2022
1,055
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.13 KB | None | 0 0
  1. #!/bin/bash
  2. # change value for your limit open files:
  3. openfiles="65535"
  4. # backup .conf files:
  5. cp -f /etc/security/limits.conf{,.bak}
  6. cp -f /etc/systemd/system.conf{,.bak}
  7. cp -f /etc/systemd/user.conf{,.bak}
  8. cp -f /etc/sysctl.conf{,.bak}
  9. # adding parameters
  10. sh -c 'echo "* soft  nproc   '$openfiles'" >> /etc/security/limits.conf'
  11. sh -c 'echo "* hard  nproc   '$openfiles'" >> /etc/security/limits.conf'
  12. sh -c 'echo "* soft  nofile  '$openfiles'" >> /etc/security/limits.conf'
  13. sh -c 'echo "* hard  nofile  '$openfiles'" >> /etc/security/limits.conf'
  14. sh -c 'echo "root  soft  nproc   '$openfiles'" >> /etc/security/limits.conf'
  15. sh -c 'echo "root  hard  nproc   '$openfiles'" >> /etc/security/limits.conf'
  16. sh -c 'echo "root  soft  nofile  '$openfiles'" >> /etc/security/limits.conf'
  17. sh -c 'echo "root  hard  nofile  '$openfiles'" >> /etc/security/limits.conf'
  18. sh -c 'echo "DefaultLimitNOFILE='$openfiles'" >> /etc/systemd/system.conf'
  19. sh -c 'echo "DefaultLimitNOFILE='$openfiles'" >> /etc/systemd/user.conf'
  20. sh -c 'echo "fs.file-max = '$openfiles'" >> /etc/sysctl.conf'
  21. sh -c 'echo "net.core.somaxconn = '$openfiles'" >> /etc/sysctl.conf'
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement