Jenkins – ulimit Not Reflected for Jenkins Slave

Jenkinslinuxsshulimit

Problem

Got java.io.IOException: Too many open files in solr indexing through jenkins.

Did some googling and found we have to set the ulimit for the box in where we are running the job.

So set the ulimit in a linux box with spec

Linux x86_64 GNU/Linux

in both of the following fashions

  1. ulimit -n 1000000

  2. /etc/security/limits.conf

    userx soft nofile 1000000
    userx hard nofile 1000000
    

Given

  1. userx is the user through which the jenkins job is being executed.
  2. when doing ssh to the box as userx manually through terminal and check ulimit -n am getting 10000000

Question

But when executing the same ulimit -n through a jenkins job, only getting 1024 which is the default.

Any advice would be much helpful?

Best Answer

Make sure pam_limits.so is enabled for su if your jenkins startup script is using "su" for user switching.

For Ubuntu Server, uncomment "session required pam_limits.so" line in /etc/pam.d/su file

sudo sed -i '/# session\s\+required\s\+pam_limits.so/ s/# *//' /etc/pam.d/su