LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   /etc/security/limits.conf --> chkconfig startup script (https://www.linuxquestions.org/questions/linux-server-73/etc-security-limits-conf-chkconfig-startup-script-886259/)

mitchSmith 06-14-2011 08:48 AM

/etc/security/limits.conf --> chkconfig startup script
 
Hi,

I have a server setup to host a web application using apache tomcat, with high throughput. Due to the high load I have increased the Maximum file descriptor limits, in /etc/security/limits.conf

Code:

*              soft    nofile          3072
*              hard    nofile          3072

I have a startup script in /etc/init.d/tomcat1, which starts the tomcat server, but fails to include the changes made to the limits.conf file. (Checked via jConsole - Still at default of 1024)

Code:

#! /bin/bash
#
# tomcat          Start/Stop the Tomcat Http/Servlet server.
#
# chkconfig: 23456 99 65
# description: Tomcat is a java based HTTP/Servlet server
# processname: tomcat
# pidfile: /var/run/tomcat.pid

# Source function library.
. /etc/init.d/functions
. /etc/profile

RETVAL=0
TOMCAT_HOME=/usr/local/apache-tomcat/
# See how we were called.

start() {
        echo -n $"Starting Tomcat "
        $TOMCAT_HOME/bin/startup.sh
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch  /var/lock/subsys/tomcat
        return $RETVAL
}

stop() {
        echo -n $"Stopping Tomcat "
        $TOMCAT_HOME/bin/shutdown.sh
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/tomcat
        return $RETVAL
}

restart() {
        stop
        start
}


case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  status)
        ps ax | grep $TOMCAT_HOME
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart}"
        exit 1
esac

exit $?

If I execute this script to start tomcat manually the limits are loaded, so why doesn't it use/load with the limits from boot?

Is there any way I can get the limits.conf to load prior to this startup script.

any information on how and when these limits are loaded would be a great help.

thanks,
Mitchell

bathory 06-14-2011 09:44 AM

Hi,

You can add:
Code:

ulimit -HSn 3072
at the beginning of your startup script, or even in tomcat's startup.sh script
Cheers

mitchSmith 06-22-2011 04:19 AM

ulimit -n works
 
Hi,

Adding ulimit -n xxxx to the startup script works, however I am would prefer to know why I cannot use the limits set in /etc/security/limits.conf?

Anyone??

Thanks
M

nooneknowme 06-23-2011 04:41 AM

Settings inside the user's profile over rights limits.conf. You might want to start by checking the user's profile.... .( bashrc , .profile depending on the shell used)


All times are GMT -5. The time now is 01:33 PM.