0

I have recently set up Xvfb on Centos 7 machine.

It is working absolutely fine.

Only problem is that if I quit putty session (remote access) it would keep running Xvfb in background but display will be gone.

So next time when I take remote access via putty first I have to type export DISPLAY=:99 again, then I start my tests.

How can I make it permanent? I don't see solution to my problem in this thread How to make exported shell variables permanent?

Update: .profile contents:

export M3_HOME=/home/aditi.a/apache-maven-3.5.4/bin
export PATH=$PATH:$M3_HOME

export JMETER_HOME=/home/aditi.a/apache-jmeter-5.0/bin
export PATH=$PATH:$JMETER_HOME

export JAVA_HOME=/usr/java/jdk1.8.0_192-amd64
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin

export DISPLAY=:99

echo variables output:

$ echo $JAVA_HOME
/usr/java/jdk1.8.0_192-amd64
$ echo $M3_HOME
/home/adit.a/apache-maven-3.5.4/bin
$ echo $DISPLAY

$

which shell I am running

$ ps -p $$
  PID TTY          TIME CMD
30678 pts/14   00:00:00 sh
  • Welcome to U&L! Which of the answers from the linked question have you tried? – JigglyNaga Oct 30 '18 at 10:12
  • I have added this line export DISPLAY=:99 in .profile file where JAVA, MAVEN environment variables are saved. Quit putty session and ran the tests, tests failed because display wasnt there, exported the display again and test run fine this time – Aditi Apte Oct 30 '18 at 10:47
  • 1
    Which shell are you using? Some shells will only read ~/.profile as a fallback, if some other startup file isn't present. – JigglyNaga Oct 30 '18 at 10:57
  • Do you mean in order to get permanently running the display this is the correct way?. To answer question, I am sure that it is the correct .profile file because it is reading Maven, Jmeter, Java from there perfectly. – Aditi Apte Oct 30 '18 at 17:29
  • Could you edit your question to show the contents of your .profile, and confirm that the other variables set there do take effect (when you connect through putty/ssh)? – JigglyNaga Oct 30 '18 at 17:58
  • @JigglyNaga done. – Aditi Apte Oct 31 '18 at 03:27
  • 1
    I also asked you to confirm that the other variables in there are set as expected: When you've connected via putty, and you type echo $JAVA_HOME, or echo $M3_HOME, or echo $DISPLAY, what is the result? – JigglyNaga Oct 31 '18 at 07:41
  • added, please check. It is black for $DISPLAY – Aditi Apte Oct 31 '18 at 12:12
  • And which shell are you using? (See Which shell am I running on? if you're not sure.) If it's bash, do either .bash_profile or .bash_login exist? – JigglyNaga Oct 31 '18 at 12:29
  • added output of ps -p $$ – Aditi Apte Oct 31 '18 at 14:24
  • That all looks like it should work. When the shell reads that .profile, it will set DISPLAY along with the other variables. When I recreate the exact steps you've described (Centos 7, shell=/usr/bin/sh, set DISPLAY in ~/.profile, connect via Putty), DISPLAY is set. So there must be something else non-standard about your setup, or a missing step you've not mentioned. If your problem can't be reproduced by anyone else, there's no way to investigate, and a "fix" won't be useful to anyone else. – JigglyNaga Oct 31 '18 at 15:31
  • You might try adding more echo display=$DISPLAY lines at the start and end of .profile to see whether .profile isn't being (fully) used, or something else is unsetting the variable afterwards. – JigglyNaga Oct 31 '18 at 15:32

1 Answers1

0

I second what @JigglyNaga said, there is nothing wrong/missing after looking at your .profile file.

Only thing I would suggest copy same contents at

/home/aditi.a/.profile and .bashrc
/root/.profile and .bashrc files

paul
  • 116