ulimit命令參數及用法

來源:互聯網
上載者:User


ulimit命令參數及用法 功能說明:控制shell程式的資源。 補充說明:ulimit為shell內建指令,可用來控制shell執行程式的資源。 參  數: -a   顯示目前資源限制的設定。 -c   設定core檔案的最大值,單位為區塊。 -d    <資料節區大小> 程式資料節區的最大值,單位為KB。 -f     <檔案大小> shell所能建立的最大檔案,單位為區塊。 -H  設定資源的硬性限制,也就是管理員所設下的限制。 -m    <記憶體大小> 指定可使用記憶體的上限,單位為KB。-n     <檔案數目> 指定同一時間最多可開啟的檔案數。-p     <緩衝區大小> 指定管道緩衝區的大小,單位512位元組。-s     <堆疊大小> 指定堆疊的上限,單位為KB。-S  設定資源的彈性限制式。 -t   指定CPU使用時間的上限,單位為秒。 -u    <程式數目> 使用者最多可開啟的程式數目。 -v    <虛擬記憶體大小>  指定可使用的虛擬記憶體上限,單位為KB。  www.2cto.com  ulimit -a來查看所有限制值 01core file size          (blocks, -c) 002data seg size           (kbytes, -d) unlimited03scheduling priority             (-e) 004file size               (blocks, -f) unlimited05pending signals                 (-i) 25659006max locked memory       (kbytes, -l) 6407max memory size         (kbytes, -m) unlimited08open files                      (-n) 102409pipe size            (512 bytes, -p) 810POSIX message queues     (bytes, -q) 81920011real-time priority              (-r) 012stack size              (kbytes, -s) 1024013cpu time               (seconds, -t) unlimited14max user processes              (-u) 8092015virtual memory          (kbytes, -v) unlimited16file locks                      (-x) unlimited 使用命令ulimit -HSn 65536可以立即生效. ulimit -u 80920 在centos 6.2不能立即生效,還需要修改 vim /etc/security/limits.d/90-nproc.conf     原因應該是新特性  www.2cto.com  1# Default limit for number of user's processes to prevent2# accidental fork bombs.3# See rhbz #432903 for reasoning.4 5*          soft    nproc     80920  注:/etc/security/limits.conf    www.2cto.com  limits.conf的工作原理:   limits.conf的後端是這樣工作的:limits.conf是pam_limits.so的設定檔,然後/etc/pam.d/下的應用程式調用pam_***.so模組。譬如說,當使用者訪問伺服器,服務程式將請求發送到PAM模組,PAM模組根據服務名稱在/etc/pam.d目錄下選擇一個對應的服務檔案,然後根據服務檔案的內容選擇具體的PAM模組進行處理。limits.conf的格式01#<domain> can be:02#        - an user name03#        - a group name, with @group syntax04#        - the wildcard *, for default entry05#        - the wildcard %, can be also used with %group syntax,06#          for maxlogin limit07設定需要被限制的使用者名稱,組名前面加@和使用者名稱區別。也可以用萬用字元*來做所有使用者的限制。08#<type> can have the two values:09#        - "soft" for enforcing the soft limits10#        - "hard" for enforcing hard limits11hard 表明系統中所能設定的最大值。soft 的限制不能比hard 限制高。 www.2cto.com  12#<item> can be one of the following:13#        - core - limits the core file size (KB)14           core - 限制核心檔案的大小15#        - data - max data size (KB)16           date - 最大資料大小17#        - fsize - maximum filesize (KB)18           fsize - 最大檔案大小19#        - memlock - max locked-in-memory address space (KB)20           memlock - 最大鎖定記憶體位址空間21#        - nofile - max number of open files22           nofile - 開啟檔案的最大數目23#        - rss - max resident set size (KB)24           rss - 最大持久設定大小25#        - stack - max stack size (KB)26           stack - 最大棧大小27#        - cpu - max CPU time (MIN)28           cpu - 以分鐘為單位的最多 CPU 時間29#        - nproc - max number of processes30           noproc - 進程的最大數目31#        - as - address space limit (KB)32           as - 地址空間限制33#        - maxlogins - max number of logins for this user34           maxlogins - 此使用者允許登入的最大數目35#        - maxsyslogins - max number of logins on the system36#        - priority - the priority to run user process with37#        - locks - max number of file locks the user can hold38#        - sigpending - max number of pending signals39#        - msgqueue - max memory used by POSIX message queues (bytes)40#        - nice - max nice priority allowed to raise to values: [-20, 19]41#        - rtprio - max realtime priority42#43#<domain>      <type>  <item>         <value>44#45 46#*               soft    core            047#*               hard    rss             1000048#@student        hard    nproc           2049#@faculty        soft    nproc           2050#@faculty        hard    nproc           5051#ftp             hard    nproc           052#@student        -       maxlogins       453 54# End of file55mysql                soft    core            204800056mysql                hard    core            204800057mysql                soft    nofile          81920058mysql                hard    nofile          819200如果遇到“段錯誤”(segmentation fault)這樣的問題,這主要就是由於Linux系統初始的堆棧大小(stack size)太小,可以使用ulimit  -s  www.2cto.com  core - 限制核心檔案的大小   何謂core檔案,當一個程式崩潰時,在進程當前工作目錄的core檔案中複製了該進程的儲存映像。core檔案僅僅是一個記憶體映象(同時加上調試資訊),主要是用來調試的。 core檔案是個二進位檔案,需要用相應的工具來剖析器崩潰時的記憶體映像。  nofile -開啟檔案的最大數目   對於需要做許多通訊端串連並使它們處於開啟狀態的應用程式而言,最好通過使用 ulimit –n,或者通過設定nofile 參數,為使用者把檔案描述符的數量設定得比預設值高一些 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.