• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Solaris : How to set limit on the maximum number of open files per process

by admin

The maximum limit of open files per process can be limited by setting a hard limit and/or a soft limit. The hard limit can be set by the system administrator and be decreased by any user, whereas the soft limit can be set by any user, up to the hard limit. This document describes the various methods available in Solaris 10 and Solaris 11 for setting the limit for the maximum number of open files per process.

Types of limits

1. hard limit : The hard limit (/etc/system parameter rlim_fd_max or the privileged level of resource control process.max-file-descriptor) is the limit for the maximum number of open files per process which is set by the system administrator. It is meant to be the upper limit for all processes running on a system (when using rlim_fd_max) or in a project (when using the resource control). Any user can decrease the hard limit but not increase it.

2. soft limit : The soft limit (/etc/system parameter rlim_fd_cur or the basic level of resource control process.max-file-descriptor) can be set by any user, up to the hard limit.

Note: There is no limit for the number of open files per Solaris system. The number of files which can be opened on Solaris 10 and above is only limited by the amount of available memory.

Setting the limit

1. method 1 (deprecated) : Parameter rlim_fd_cur in /etc/system
Parameter rlim_fd_cur can be set to a value up to the value of rlim_fd_max (for which the default is 65536, which can also be set to a different value in /etc/system). This method of setting the file descriptor limit is no longer recommended in Solaris 10 and Solaris 11. In general, it is recommended to use resource controls in favor of /etc/system parameters where available.

2. method 2 : Resource control process.max-file-descriptor
By using the resource control process.max-file-descriptor instead of /etc/system parameter rlim_fd_max, the system administrator can change the value for the maximum number of open files per process while the system remains running, without having to reboot the server. The other advantage is that processes of other projects are not affected.

For changing the hard limit for project PRJ from the default 65536 to 4096, use the following command:

# projmod -s -K "process.max-file-descriptor=(priv,4096,deny)" PRJ

For changing the soft limit for project PRJ from the default 256 to 1024, use the following command:

# projmod -s -K "process.max-file-descriptor=(basic,1024,deny) PRJ

3. method 3 : limit/ulimit commands
It is also possible to set the limit for the maximum number of open files per process using the limit or ulimit commands, up to the hard limit set in /etc/system or to the priv level for process.max-file-descriptor. The limit is set for the shell and all commands executed in that shell, even if a project with resource control process.max-file-descriptor is defined for that user.

a. setting soft limit
For increasing the soft limit from the default 128 to 512 in csh , use the following command:

# limit descriptors 512

For increasing the soft limit from the default 128 to 512 in ksh or sh, use the following command:

# ulimit -Sn 512

b. setting hard limit
For decreasing the hard limit from the default 65536 to 4096 in csh, use the following command:

# limit -h descriptors 4096

For decreasing the hard limit from the default 65536 to 4096 in ksh or sh, use the following command:

# ulimit -Hn 4096

4. method 4 : plimit command
The plimit command can be used to set the limit for the maximum number of open files of an already running process. For example, the following command will set the soft limit to 2048 and the hard limit to 4096 for process 13179:

# plimit -n 2048,4096 13179

Verify the limit

The following commands can be used to check the value for the limit of the maximum number of open files of a running process (Again, in all examples, 13179 is used for the process id):

The prctl command:

# prctl -n process.max-file-descriptor 13179 
process: 13179: sleep 1200
NAME    PRIVILEGE       VALUE    FLAG   ACTION               RECIPIENT
process.max-file-descriptor
        basic             256       -   deny                     13179
        privileged      65.5K       -   deny                         -
        system          2.15G     max   deny                         -

The plimit command:

# plimit 13179
13179: sleep 1200
   resource              current         maximum
  time(seconds)         unlimited       unlimited
  file(blocks)          unlimited       unlimited
  data(kbytes)          unlimited       unlimited
  stack(kbytes)         10240           unlimited
  coredump(blocks)      unlimited       unlimited
  nofiles(descriptors)  256             65536
  vmemory(kbytes)       unlimited       unlimited

The pfiles command:

# pfiles 13179 
13179: sleep 1200
Current rlimit: 256 file descriptors
0: S_IFCHR mode:0620 dev:542,0 ino:500877638 uid:60004 gid:7 rdev:133,1
O_RDWR
/dev/pts/1
offset:38001
1: S_IFCHR mode:0620 dev:542,0 ino:500877638 uid:60004 gid:7 rdev:133,1
O_RDWR
/dev/pts/1
offset:38001
2: S_IFCHR mode:0620 dev:542,0 ino:500877638 uid:60004 gid:7 rdev:133,1
O_RDWR
/dev/pts/1
offset:38001
Solaris : How to find number of open files by a process

Filed Under: Solaris, Solaris 11

Some more articles you might also be interested in …

  1. Solaris 11 IPS hand-on LAB – Creating IPS repository
  2. How to Set the TimeZone in Solaris 10,11
  3. How Passwordless SSH works in Linux / UNIX
  4. What is SUID, SGID and Sticky bit ?
  5. Solaris Performance troubleshooting : Disk (I/O) performance issues
  6. Complete Hardware Reference : SPARC T3-1 / T3-2 / T3-4
  7. How to troubleshoot Solaris 10 SMF (Service Management Facility) related issues
  8. Oracle Solaris 11 Package Naming scheme ( version format )
  9. How to measure NIC Performance/Throughput in Solaris 11 using iftop
  10. The ultimate Solaris networking interview questions

You May Also Like

Primary Sidebar

Recent Posts

  • qsub Command Examples in Linux
  • qsub: command not found
  • qrcp Command Examples in Linux
  • qmrestore Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright