【发布时间】:2015-03-11 03:27:27
【问题描述】:
每次我打开一个新终端时,都会显示这些消息:
-bash: ulimit: open files: cannot modify limit: Invalid argument
-bash: ulimit: max user processes: cannot modify limit: Operation not permitted
我之前确实修改过 ulimit,但是我忘记了我做了什么。那么我该如何解决这个问题,请帮助。谢了
----更新----
我的主目录中没有 .profile 或 .bashrc。但我有一个 ~/.bash_profile 和 /etc/bashrc。 ~/.bash_profile 看起来像
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GF'
alias ll='ls -GFl'
export JAVA_HOME=$(/usr/libexec/java_home)
export LC_CTYPE="en_US.UTF-8"
/etc/bashrc 看起来像:
# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
return
fi
PS1='\h:\W \u\$ '
# Make bash check its window size after a process completes
shopt -s checkwinsize
# Tell the terminal about the working directory at each prompt.
if [ "$TERM_PROGRAM" == "Apple_Terminal" ] && [ -z "$INSIDE_EMACS" ]; then
update_terminal_cwd() {
# Identify the directory using a "file:" scheme URL,
# including the host name to disambiguate local vs.
# remote connections. Percent-escape spaces.
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}
PROMPT_COMMAND="update_terminal_cwd; $PROMPT_COMMAND"
fi
我没有看到任何关于 ulimit 的内容。
----更新----
sudo ulimit -a -H
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) unlimited
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 65532
cpu time (seconds, -t) unlimited
max user processes (-u) 1064
virtual memory (kbytes, -v) unlimited
sudo ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 4864
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 709
virtual memory (kbytes, -v) unlimited
【问题讨论】:
-
查看您的配置文件:
~/.profile、~/.bash_profile、~/.bashrc并找到您尝试调用ulimit的位置。您可能需要查看/etc,但可能不会,除非您在那里修改配置文件等。 -
将
set -x添加到~/.bash_profile的顶部,将set +x添加到底部。创建一个新的终端窗口。您应该看到~/.bash_profile执行的命令的跟踪。找出生成错误消息的位置。如果它出现在跟踪代码之前或之后(您可能想在set +x之后回显类似echo "Trace off"的内容),那么您知道~/.bash_profile没有产生问题;这是另一个文件。您可能必须阅读Bash 手册才能了解它读取的其他文件。一次调试一个文件。 -
@JonathanLeffler 既不是 /etc/bashrc 也不是 ~/.bash_profile :(
-
ulimit -a -H和ulimit -a的值是多少?将输出添加到您问题中的信息中。 -
@JonathanLeffler 已更新