为什么/root/.bash_profile中的命令启动两次?
-
14-12-2019 - |
题
这是我的 /root/.bash_profile
:
export DISPLAY=:42 && cd /home/df/SimulatedRpu-ex/bin && ./SimulatedRpu-V1 &
当我启动服务器时,我运行 ps aux | grep SimulatedRpu
这是输出:
root 2758 0.2 1.0 62316 20416 ? Sl 14:35 0:00 ./SimulatedRpu-V1
root 3197 0.5 0.9 61428 19912 pts/0 Sl 14:35 0:00 ./SimulatedRpu-V1
root 3314 0.0 0.0 5112 716 pts/0 S+ 14:35 0:00 grep SimulatedRpu
因此,程序打印有关端口的错误消息已被使用。但为什么命令在 /root/.bash_profile
开始两次?请帮助我,谢谢!顺便说一句,我使用Redhat Enterprise 5.5
解决方案
每次登录时都会读取该个人资料。因此只需登录即可运行 ps aux | grep SimulatedRpu
, ,您再次运行该配置文件,从而启动一个新进程。
您应该将命令放入 初始化脚本 反而。
[编辑] 你还应该运行 Xvnc
在同一个脚本中 - 这样,您可以与您的应用程序一起启动和停止显示服务器。
其他提示
尝试一下就像
if ! ps aux | grep '[S]imulateRpu'; then
export DISPLAY=:42 && cd /home/df/SimulatedRpu-ex/bin && ./SimulatedRpu-V1 &
fi;
这样它会首先检查应用程序是否尚未运行。S 周围的 [] 是为了防止 grep 找到自己;)
不隶属于 StackOverflow