bash 登录和 shell 提示之间有 10 秒的延迟。
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8413975/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
10 second delay between login and shell prompt.
提问by
I've got a strange problem. After I enter my password on a debian 6.0 system, I get the motd but then there is a 5-10 second pause until I get a shell prompt. If I press ctrl-c during that pause the prompt comes up instantly. What could be happening here? Am I killing the login process? Why might it be taking so long to invoke bash? I appreciate any suggestions.
我有一个奇怪的问题。在 debian 6.0 系统上输入我的密码后,我得到了 motd,但是在我得到 shell 提示之前有 5-10 秒的暂停。如果我在暂停期间按 ctrl-c,提示会立即出现。这里会发生什么?我正在杀死登录过程吗?为什么调用 bash 可能需要这么长时间?我很感激任何建议。
Thanks
谢谢
回答by
You can debug bash shell scripts using set -xand set +x. The set -xcommand enables debug mode and the set +xcommand disables it.
您可以使用set -x和调试 bash shell 脚本set +x。该set -x命令启用调试模式,该set +x命令禁用它。
Putting set -xat the top of your $HOME/.bash_profile should cause debug information to be printed for your personal shell initialisation files. If as you say you get a 10 second delay you should be able to track it down quite easily. If This doesn't shed any light then go for the system wide initialisation file /etc/profile.
放在set -x$HOME/.bash_profile 的顶部应该会导致为您的个人 shell 初始化文件打印调试信息。如果如您所说,您有 10 秒的延迟,您应该能够很容易地找到它。如果这没有任何意义,那么去寻找系统范围的初始化文件/etc/profile。
回答by cnicutar
It's likely there's something in your .bashrcor .bash_profile. Or maybe some other startup file (/etc/profileet al).
您的.bashrc或.bash_profile. 或者也许是其他一些启动文件(/etc/profile等)。
回答by aalleexxaannddrree
Same problem as John Rix for me. /opt/vmware/bin/ovfenv was the culprit.
对我来说和 John Rix 一样的问题。/opt/vmware/bin/ovfenv 是罪魁祸首。
I found this post after doing the following investigation: starting another bash would take up to 30 seconds on a CentOS6
我在做了以下调查后发现了这篇文章:在 CentOS6 上启动另一个 bash 最多需要 30 秒
strace bash
shows few lines before it hangs:
在挂起之前显示几行:
read(3, "LANG=`/opt/vmware/bin/ovfenv --q"..., 183) = 183
Removed the script from being executed with:
删除了正在执行的脚本:
mv /etc/profile.d/zzzz-vamilocale.sh /etc/profile.d/zzzz-vamilocale.sh.ko

