LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ssh command, nohup and startx (https://www.linuxquestions.org/questions/linux-newbie-8/ssh-command-nohup-and-startx-829595/)

j_kubik 08-31-2010 02:33 PM

ssh command, nohup and startx
 
Hello

I am having a server, which normaly doesn't use X. However i am using Xvfb when i connect to it via SSH, and seting tunneling to vnc port. Server script looks like

Code:

#!/bin/bash

xset -display :25 -q &> /dev/null

if [ $? != 0 ]; then
  echo "Starting X'es"
  nohup startx startkde -- Xvfb :25 -screen 0 1270x740x24 &> /dev/null &
else
  echo "X'es started"
fi

x11vnc -display :25

When I log in interactively via ssh, and then run the script, the Xvfb session lasts as long as i don't log out of kde - which means that i can freely create and close VNC connections without killing X sever.
However when i use ssh remote command to automate process (simply a saved putty session with set up host address, tunneling and script name) then as soon as i close VNC connection and script ends, the Xvfb also gets killed. It's happening despite using nohup. Is this behavior normal? How to make Xvfb last?

chrism01 08-31-2010 11:15 PM

Not sure if this will work, but try 'source'ing the script, so it runs in the 'current' shell rather than invoking a sub-shell.

j_kubik 09-01-2010 03:08 AM

Quote:

Originally Posted by chrism01 (Post 4084342)
Not sure if this will work, but try 'source'ing the script, so it runs in the 'current' shell rather than invoking a sub-shell.

Not sure what do you mean by 'source'ing script - i tried removing #!/bin/bash from begining of script file, but it didn't change anything. In both cases pstree looked like
Code:

    |-sshd-+-sshd---sshd---bash---konsole---bash---pstree
    |      `-sshd---sshd---runvnc-+-startx---xinit-+-Xvfb
    |                            |                `-startkde---kwrapper
    |                          `  -x11vnc

so i am guessing that there is only one shell created in both cases.

I think that difference between interactive and non-interactive mode of ssh may be in signals sent when terminating applications.

estabroo 09-01-2010 07:41 AM

when you do the ssh try adding -t -t to the options, could be that something is checking to see if it's in a tty or not and is behaving differently based on that

j_kubik 09-14-2010 03:46 PM

Sorry but it seems that i haven't stressed it enough - i am not using ssh, i am using putty from windows machine. I tried plain ssh (on linux client) and it works fine. problem shows up only with putty - i have no idea about possible differences.
I am sure that putty forces creating tty (as -t -t would also have done). Anyway it's not necessary, cause on linux client command like
Code:

ssh -f -L 55$1:localhost:5900 [user]@[host] /path/to/runvnc
is enough.

estabroo 09-14-2010 08:58 PM

have you tried cygwin ssh and see if it works?

chrism01 09-15-2010 12:08 AM

Putty can go via telnet or ssh; your choice; just specify Port 22

j_kubik 06-24-2011 02:09 PM

Quote:

Putty can go via telnet or ssh; your choice; just specify Port 22
True. But server that Iam connecting to doesn't necesairly need to use telnet, right ;)

Anyway, I guess using telnet it would be exactly the same.


All times are GMT -5. The time now is 07:56 AM.