<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616013#M235071</link>
    <description>Hi Shiv:&lt;BR /&gt;&lt;BR /&gt;The script's variable 'maxfiles' is established with:&lt;BR /&gt;&lt;BR /&gt;# maxfiles=`ulimit -H -n`&lt;BR /&gt;&lt;BR /&gt;The HARD limit of the kernel parameter 'maxfiles_lim' is requested with '-H -n' [ see the man pages for sh-posix() ].&lt;BR /&gt;&lt;BR /&gt;If the request was successful and the returned value does not equal 1024 [line-2], then a test is made to see if the returned value is "unlimited" [line-3].  If it is "unlimited" then the script's 'maxfiles' variable is set to 1025.&lt;BR /&gt;&lt;BR /&gt;The script continues and finally sets the SOFT limit to the smaller of 1024 or the value of $maxfiles.&lt;BR /&gt;&lt;BR /&gt;The idea is that the kernel parameter 'maxfiles' is the number of files a process is allowed to have open at any one time.  This is called the SOFT limit.  This value may be increased by a user, but not beyond the HARD limit.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Wed, 31 Aug 2005 14:03:23 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2005-08-31T14:03:23Z</dc:date>
    <item>
      <title>shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616012#M235070</link>
      <description>Dear sirs,&lt;BR /&gt;&lt;BR /&gt;I have a shell script described below:&lt;BR /&gt;&lt;BR /&gt;# limit the number of open file descriptors&lt;BR /&gt;resetFd() {&lt;BR /&gt;  if [ ! -n "`uname -s |grep -i cygwin || uname -s |grep -i windows_nt`" ]&lt;BR /&gt;  then&lt;BR /&gt;    maxfiles=`ulimit -H -n`&lt;BR /&gt;    if [ ! $? -a "${maxfiles}" != 1024 ]; then&lt;BR /&gt;      if [ "${maxfiles}" = "unlimited" ]; then&lt;BR /&gt;        maxfiles=1025&lt;BR /&gt;      fi&lt;BR /&gt;      if [ "${maxfiles}" -lt 1024 ]; then&lt;BR /&gt;        ulimit -n ${maxfiles}&lt;BR /&gt;      else&lt;BR /&gt;        ulimit -n 1024&lt;BR /&gt;      fi&lt;BR /&gt;    fi&lt;BR /&gt;  fi&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;In the above code what is the meaning of :-&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;maxfiles=`ulimit -H -n`&lt;BR /&gt;    if [ ! $? -a "${maxfiles}" != 1024 ]; then&lt;BR /&gt;      if [ "${maxfiles}" = "unlimited" ]; then&lt;BR /&gt;        maxfiles=1025&lt;BR /&gt;      fi&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;Also please explain the final outcome of the script.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shiv&lt;BR /&gt;</description>
      <pubDate>Wed, 31 Aug 2005 13:43:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616012#M235070</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2005-08-31T13:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616013#M235071</link>
      <description>Hi Shiv:&lt;BR /&gt;&lt;BR /&gt;The script's variable 'maxfiles' is established with:&lt;BR /&gt;&lt;BR /&gt;# maxfiles=`ulimit -H -n`&lt;BR /&gt;&lt;BR /&gt;The HARD limit of the kernel parameter 'maxfiles_lim' is requested with '-H -n' [ see the man pages for sh-posix() ].&lt;BR /&gt;&lt;BR /&gt;If the request was successful and the returned value does not equal 1024 [line-2], then a test is made to see if the returned value is "unlimited" [line-3].  If it is "unlimited" then the script's 'maxfiles' variable is set to 1025.&lt;BR /&gt;&lt;BR /&gt;The script continues and finally sets the SOFT limit to the smaller of 1024 or the value of $maxfiles.&lt;BR /&gt;&lt;BR /&gt;The idea is that the kernel parameter 'maxfiles' is the number of files a process is allowed to have open at any one time.  This is called the SOFT limit.  This value may be increased by a user, but not beyond the HARD limit.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 31 Aug 2005 14:03:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616013#M235071</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-08-31T14:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616014#M235072</link>
      <description>Hello Shivkumar,&lt;BR /&gt;&lt;BR /&gt;In general this code is attempting to test for the ulimit's upper limit.  It goes as follows:&lt;BR /&gt;&lt;BR /&gt;maxfiles=`ulimit -H -n` - This sets the maxfiles to the value returned by the command "ulimit -H -n" which will be a numberic value.&lt;BR /&gt;&lt;BR /&gt;if [ ! $? -a "${maxfiles}" != 1024 ]; - This is testing the return code of the previous command ($?) to see if it is not (!) 0.  And (-a) the maxfiles returned by "ulimit -H -n" is not 1024 (!= 1024).&lt;BR /&gt;&lt;BR /&gt;if [ "${maxfiles}" = "unlimited" ]; - This checks to see if "ulimit -H -n" returned "unlimited".  If the above if and this if are both true, maxfiles will be set to 1025.</description>
      <pubDate>Wed, 31 Aug 2005 14:11:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616014#M235072</guid>
      <dc:creator>CSG Office</dc:creator>
      <dc:date>2005-08-31T14:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616015#M235073</link>
      <description>Sets "maxfiles" to the number of file descriptors. If their are unlimited it sets it to 1025, so that the numeric comparison later in the script has no problem.&lt;BR /&gt; &lt;BR /&gt;The final result is to set the max number of open file descriptors to a maximum of 1024.&lt;BR /&gt; &lt;BR /&gt;PS- That form of the ulimit command is not only available in the posix shell.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Wed, 31 Aug 2005 14:12:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616015#M235073</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-08-31T14:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616016#M235074</link>
      <description>Oops-&lt;BR /&gt; &lt;BR /&gt;Meant to say "only available in posix sh"&lt;BR /&gt; &lt;BR /&gt;Rod Hills</description>
      <pubDate>Wed, 31 Aug 2005 14:14:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616016#M235074</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-08-31T14:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616017#M235075</link>
      <description>this code is specific to sh-posix shell.&lt;BR /&gt;ulimit -H -n is availabe in sh shell only. If you plan to run it on ksh, then you will have to do /usr/bin/ulimit -H -n</description>
      <pubDate>Wed, 31 Aug 2005 14:16:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/3616017#M235075</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-08-31T14:16:37Z</dc:date>
    </item>
  </channel>
</rss>

