LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-31-2010, 03:33 PM   #1
j_kubik
LQ Newbie
 
Registered: Aug 2010
Posts: 16

Rep: Reputation: 1
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?

Last edited by j_kubik; 08-31-2010 at 03:35 PM.
 
Old 09-01-2010, 12:15 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
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.
 
Old 09-01-2010, 04:08 AM   #3
j_kubik
LQ Newbie
 
Registered: Aug 2010
Posts: 16

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by chrism01 View Post
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.
 
Old 09-01-2010, 08:41 AM   #4
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,117
Blog Entries: 2

Rep: Reputation: 113Reputation: 113
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
 
Old 09-14-2010, 04:46 PM   #5
j_kubik
LQ Newbie
 
Registered: Aug 2010
Posts: 16

Original Poster
Rep: Reputation: 1
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.
 
Old 09-14-2010, 09:58 PM   #6
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,117
Blog Entries: 2

Rep: Reputation: 113Reputation: 113
have you tried cygwin ssh and see if it works?
 
Old 09-15-2010, 01:08 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Putty can go via telnet or ssh; your choice; just specify Port 22
 
Old 06-24-2011, 03:09 PM   #8
j_kubik
LQ Newbie
 
Registered: Aug 2010
Posts: 16

Original Poster
Rep: Reputation: 1
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Difficulty in understanding nohup Command. sowraj Linux - Newbie 2 01-28-2010 02:59 AM
Jobs started with nohup aborts after closing ssh awalls Linux - Software 4 09-28-2007 06:26 AM
nohup command used but process is still killed helptonewbie Linux - Newbie 4 02-13-2007 05:44 PM
problem with nohup command and nohup file size vbseeker Linux - General 1 09-17-2006 12:36 PM
nohup command chbin Slackware 1 03-31-2005 04:47 AM


All times are GMT -5. The time now is 03:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration