为什么/root/.bash_profile中的命令启动两次?
问题描述:
这里是我的/root/.bash_profile
:为什么/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
中的命令启动两次? 请帮帮我,谢谢!顺便说一句,我使用红帽企业版5.5
答
的配置文件读取每次登录的时间。因此,只要登录到运行ps aux | grep SimulatedRpu
,运行配置文件一次,并由此开始一个新的过程。
你应该把命令到init script代替。
[编辑]你也应该在同一个脚本中运行Xvnc
- 这样,你可以启动和停止显示服务器与你的应用程序。
答
尝试像
if ! ps aux | grep '[S]imulateRpu'; then
export DISPLAY=:42 && cd /home/df/SimulatedRpu-ex/bin && ./SimulatedRpu-V1 &
fi;
这样,它首先会检查,如果应用程序尚未运行。在[]中的S周围是防止grep的从寻找自身)
+0
谢谢您的快速答复!我也写了喜欢你写字我跑VNCserver.So它不是剂量的work.Finally Qt的程序,我用另一种方式来处理这个问题的一个壳。 – smarthand 2012-03-15 14:19:18
尝试在不同的行或用;在之间。 – Corbin 2012-03-15 06:44:23
谢谢你的回答!我跟着你说的,我解决了这个问题。祝你好运! – smarthand 2012-03-15 14:27:05