在 CentOS 中,您可以使用以下方法之一来查看进程的 ulimit 值:
方法 1:使用 ulimit 命令
ulimit -a 命令,然后按 Enter 键。这将显示当前 shell 会话的所有 ulimit 值。示例输出:
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 128160
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 4096
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
方法 2:查看 /etc/security/limits.conf 文件
sudo cat /etc/security/limits.conf 命令,然后按 Enter 键。这将显示系统的 ulimit 配置。示例输出:
# Example of the limit configuration file.
#
# The line below shows how to set all limits to 4096 (4K).
* soft nproc 4096
* hard nproc 4096
* soft nofile 4096
* hard nofile 4096
请注意,这些方法显示的是当前 shell 会话或系统的 ulimit 值。如果您想要查看特定进程的 ulimit 值,您需要先找到该进程的 PID(进程 ID),然后使用 prlimit 命令。例如:
ps -ef | grep <process_name>
prlimit --pid <PID> --all
将 <process_name> 替换为您要查找的进程名称,将 <PID> 替换为进程 ID。