My Favorites

Close

Please to see your favorites.

  • Bookmark
  • Email Document
  • Printer Friendly
  • Favorite
  • Rating:

Open files rlimit 1024 reached for uid xxxx

This document (3302273) is provided subject to the disclaimer at the end of this document.

Environment

Novell SUSE Linux Enterprise Server 9
Novell SUSE Linux Enterprise Server 9 Service Pack 3

Situation

Symptoms:

"/var/log/messages" show the warning "Open files rlimit 1024 reached for uid xxxx";
Using the command "ulimit -n" logged into a shell as the user corresponding to the uid xxxx the open files limit shows a value higher than 1024;
The file "/etc/security/limits.conf" has been properly modified increasing both "soft nofile" and "hard nofile" limits to values higher than 1024 for  the user having uid xxx;
The pertinent PAM related files located under "/etc/pam.d/" have been properly modified to include the line "session required pam_limits.so" .

Changes:

A previously manual executed task has been scheduled, from the user with uid xxxx, to be automatically executed by cron daemon;
If the same operations are executed manually logged into a shell as the user having uid xxxx, everything run smoothly and no errors are seen in "/var/log /messages";

In Novell SUSE Linux Enterprise Server 9 the cron daemon is not PAM aware.

Resolution

In Novell SUSE Linux Enterprise Server 9 the cron daemon is not PAM aware, any modifications made into any files under"/etc/pam.d/"will not make any difference in the cron daemon behavior, it will not use the limits specified in"/etc/security/limits.conf".

What happens is that the cron daemon use the shell "/bin/sh" as default environment and gets the limits default values from there.

There are several ways to workaround this issue and increase the limits available to a cron scheduled task, here follows 2 possible solutions:

1) Modify the file "/etc/init.d/cron" adding the line "ulimit -n 65536" (without quotes)

A good place to insert the line would be the section labeled"start)" of the cron script itself, as follow:

[...]
case "$1" in
    start)
        ulimit -n 65536 
        for al_de in {allow,deny}{,.rpmsave,.rpmorig} ; do
                if [ -f /var/spool/cron/$al_de ] ; then
                        allow_deny_move_info
                        break
                fi
        done
        echo -n "Starting CRON daemon"
        ## Start daemon with startproc(8). If this fails
        ## the echo return value is set appropriate.

        # NOTE: startproc return 0, even if service is
        # already running to match LSB spec.
        startproc $CRON_BIN

        # Remember status and be verbose
        rc_status -v
        ;;
[...]

This will increase both the Soft and Hard limits for the open files to the value 65536, and this will be effective for all the cron executed tasks. The server must be restarted to make this change effective.

2) Use the "/etc/initscript" file

As stated in the man pages for initscript (man initscript) is possible to create the file "/etc/initscript" that can be used to set things like ulimit and umask default values for every process. The following initscript will increase the Hard limits for the open files to 65536 for every process:

                # Increase the hard file descriptor limit for all processes
                # to 65536.  The soft limit is still 1024, but any unprivileged
                # process can increase it's soft limit up to the hard limit
                # with "ulimit -Sn xxx" (needs a 2.2.13 or later Linux kernel).
                ulimit -Hn 65536

                # Execute the program.
                eval exec "$4"

Please note that this way the Hard limit for open files will be increased for every process in the system, while the Soft limit will stay at default value of 1024.

Make sure to read carefully the NOTES section of the man pages:

This script is not meant as startup script for daemons or some such.  It has nothing  to  do  with  a  rc.local
style script. It's just a handler for things executed from /etc/inittab. Experimenting with this can make yoursystem un(re)bootable.

Both of the described workarounds have been tested in lab and production environments and successfully allowed the cron scheduled tasks to goes over the default 1024 limit for the open files, however the first one is less invasive and less dangerous as increase the limit only for the cron executed tasks and not for any process, like the second method does.

Additional Information

In Novell SUSE Linux Enterprise Server 10 the cron daemon has been made PAM aware and "/etc/pam.d/crond" is the PAM configuration file for the cron daemon itself. Adding the line "session required pam_limits.so" in "/etc/pam.d/crond" will make the cron daemon to use the limits specified in "/etc/security/limits.conf" for the default entry (*).

Disclaimer

This Support Knowledgebase provides a valuable tool for NetIQ/Novell/SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:3302273
  • Creation Date:21-AUG-07
  • Modified Date:27-APR-12
    • SUSESUSE Linux Enterprise Server

Did this document solve your problem? Provide Feedback

< Back to Support Search

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.


SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center