Question

Here is my /root/.bash_profile:

export DISPLAY=:42 && cd /home/df/SimulatedRpu-ex/bin && ./SimulatedRpu-V1 &

When I start my server,I run ps aux | grep SimulatedRpu and here is the output:

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

So,the program print error message about the port is already used. But why the command in /root/.bash_profile start twice? Please help me,thank you!By the way,I use Redhat Enterprise 5.5

Was it helpful?

Solution

The profile is read every time you log in. So just by logging in to run the ps aux | grep SimulatedRpu, you run the profile once more and thus start a new process.

You should put the command into an init script instead.

[EDIT] You should also run Xvnc in the same script - that way, you can start and stop the display server together with your app.

OTHER TIPS

Try it like

if ! ps aux | grep '[S]imulateRpu'; then
    export DISPLAY=:42 && cd /home/df/SimulatedRpu-ex/bin && ./SimulatedRpu-V1 &
fi;

This way it will first check if if the application is not running yet. The [] around the S are to prevent grep from finding itself ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top