HP-UX 11.x Operating
Systems - Changing the POSIX Shell's ulimit -n (File Descriptor) Setting.
Overview
|
HP-UX 11.x Operating Systems - Changing
the POSIX Shell's ulimit -n (File Descriptor) Setting.
|
Procedures
|
HP-UX 11.x Operating Systems - Changing the POSIX Shell's ulimit -n (File Descriptor) SettingIssue
This document provides information and examples on how to
change the POSIX shell's ulimit -n parameter (the resource limit for the
number of per-process file descriptors allowed in that shell's environment).
Solution
ulimit usage will be
shell-specific. For use with the POSIX
shell, refer to the sh-posix(1) manual page
and search for ulimit .
To display the current value of the file descriptor
setting in ulimit :
To display the hard limit of the file descriptor setting:
To change the soft limit of the file descriptor setting:
To confirm the new value following the change:
To change the hard limit of the file descriptor setting:
To confirm the new value following the change:
# ulimit -Hn 2048
We were able to decrease the value of the file descriptor
setting. But, if we attempt to increase it to greater than 4096 , then an error would be returned:
This is because our hard limit is also not set to
unlimited. Thus, will try to increase that to unlimited:
# ulimit -Ha n 8192 sh: ulimit: The specified value exceeds the user's allowable limit.
Again, we saw the error.
This is because soft limit of file descriptor setting
depends upon the maxfiles kernel tunable,
and the hard limit of the file descriptor setting depends upon the maxfiles_lim kernel tunable:
maxfiles < or = maxfiles_lim softlimit < or = hard limit # kctune -q maxfiles Tunable Value Expression maxfiles 4096 Default # kctune -q maxfiles _lim Tunable Value Expression Changes maxfiles_lim 4096 Default Immed
The maxfiles kernel
tunable is presently 4096 and maxfiles_lim = 4096 . Thus, if we want to set the
ulimit file descriptor setting to more than
4096 , we first need to increase the values
of the maxfiles and maxfiles_lim kernel tunables:
# kctune maxfiles=8192 NOTE: The configuration being loaded contains the following change(s) that cannot be applied immediately and which will be held for the next boot: -- The tunable maxfiles cannot be changed in a dynamic fashion. * The automatic 'backup' configuration has been updated. * The requested changes have been saved, and will take effect at next boot. Tunable Value Expression maxfiles (now) 2048 Default (next boot) 8192 8192 NOTE : changing the maxfiles tunable requires a restart of system. # kctune maxfiles _lim=8192 WARNING: The automatic 'backup' configuration currently contains the configuration that was in use before the last reboot of this system. ==> Do you wish to update it to contain the current configuration before making the requested change? y * The automatic 'backup' configuration has been updated. * The requested changes have been applied to the currently running system. Tunable Value Expression Changes maxfiles_lim (before) 4096 Default Immed (now) 8192 8192
Now, the nofiles
descriptor value may be changed in ulimit
after a restart of system.
Before setting the soft limit, we would need to increase
the hard limit:
Confirm the hard limit change:
Now, we will be able to change the soft limit of the file descriptor
setting with ulimit :
Confirm the changes:
NOTE: Changing the maxfiles and maxfiles_lim
kernel parameters also confirms that the value of soft limit and the hard
limit for the file descriptor setting in ulimit
is defaulted to the new values of maxfiles
and maxfiles_lim after a system restart.
If we need to set the specific value for all users, we can
set this in /etc/profile .
If we want to do this for a particular user, then we can
edit their .profile , adding a line that
has the following format:
|
Keywords.
|
ulimit.
|