LinuxQuestions.org
Visit Jeremy's Blog.
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 02-18-2004, 01:29 PM   #1
gauge73
Member
 
Registered: Jan 2003
Location: Dallas, TX
Distribution: Fedora Core 4
Posts: 420

Rep: Reputation: 30
Really basic stuff here


Okay, I have on my linux machine a VNC desktop and a SSH server running at all times. The machine runs headless and this is how I connect to it. I do so from my XP machine, from school, from friends' houses, etc. There are all kinds of shell programs that I want to leave running, and here's where my question comes in. VNC is really cool, but if you're running a shell in a 1024X768 window on a 1600X1200 screen and it doesn't update well all the time and has incorrectly-colored pixles in it, it gets kind of annoying. When running shell programs I much prefer SSH. However, I can't keep them running unless I keep the computer connected to the SSH server. Is there any way around this?

So, basically, I'm asking if there is any way to keep a shell program running after disconnecting from the SSH program. These are interactive programs, mind you, not just programs that I can run in the background. For example, I use a text-based gnutella client. I don't want to suspend the program or it won't continue downloading. I just want to sort of suspend the shell and be able to reconnect to it later and perhaps from a different computer.

I know this is a weird question and the answer is probably that I can't do it, but I'm really interested in being able to do this, so please humor me. Thanks in advance for any help.
 
Old 02-18-2004, 01:40 PM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
but...as far as I'm understood, programs that are sent to background, shouldn't "suspend" (because linux can run several processes at the same time, not like windows does...) but run quite normally, and stop ("suspend") only if they need some input from the user...

correct me if I'm wrong, but that's what I think? I've had no problems sending any app/process to background & closing shell..am I just weird or what?

so you're saying that running

gnutella &

(well I don't know the name of the binary, but let's say it's gnutella) makes gnutella suspend? or what?
 
Old 02-18-2004, 01:44 PM   #3
gauge73
Member
 
Registered: Jan 2003
Location: Dallas, TX
Distribution: Fedora Core 4
Posts: 420

Original Poster
Rep: Reputation: 30
Well, the issue is that I need to be able to bring it back to the shell and get to an interactive interface again. I also don't know much about running things with the & after them. I thought that made them independent of the shell, but apparently I was wrong because I tried to open xmms by opening a shell and entering xmms & as a command and when I closed the shell xmms closed as well. So, perhaps I need clarification on this.

But, like I said, the issue is that I need to be able to get back to the interactive interface, AND it has to continue running in the background (so downloads continue). Is this possible?
 
Old 02-18-2004, 06:52 PM   #4
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Debian + Ubuntu
Posts: 4,358

Rep: Reputation: 57
I have read that some people use screen to accomplish this. Basically they login through SSH, run screen and have their applications running. They then exit SSH. Because screen is still running, their programmes remain running too. I've not used it myself, but when I read about it it seemed logical enough.
 
Old 02-19-2004, 08:43 AM   #5
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
mm haven't ever tried that...

anyway, if you wish to try the &-thingie (the & after the command makes the process go background, so that you can do other stuff and the process itself should run "silently" but still run..), here's how it works:

- a process is sent to background in it's startup by giving & at the end of the line and then pressing return
- a process sent to background gets something like a symbolic number (what was the exact name?), so that the first one is known as %1, second %2, third %3 and so on...so it's a percent-mark and the number which starts from 1.
- a process is called back to foreground (from background) via "fg" command: let's say you have three background processes. typing "jobs" in terminal (without quotes) tells you you have three processes and shows their numbers (1, 2 and 3). now you want to get process 2 back to your screen (foreground) - you give the following command in terminal:

fg %2

that takes the job number 2 (you see the numbers corresponding the processnames with the jobs -command) back to foreground. I've also heard about "bg" command which should send processes (running) to background, but haven't tried it... a running process can (as far as I know) be sent to background by giving CTRL+Z when it's active on your screen. and then brought back with fg.

so to get a process to background, start it with & and to get it back foreground by giving a command "fg" without quotes - running program is sent to background with ^Z (ctrl+Z)

EDIT:

now I remembered it...the reason, why apps shut down when you close the shell it's because of linux's (and unix-like os's) way of managing processes: each process may have it's subprocesses, like a terminal (a process) can run other apps from it if you run them by typing the app name in terminal - these apps run from the terminal are the subprocesses of the terminal. now when you kill a process (the terminal), all it's subprocesses are also killed - so every app you start from the terminal, are also killed when you shoot it down. solution? you really should get your apps started as subprocesses of something that won't shut down when you cut your connection to the shell..this is how the way Thymox said works I guess.

Last edited by b0uncer; 02-19-2004 at 08:47 AM.
 
Old 02-19-2004, 09:18 AM   #6
gauge73
Member
 
Registered: Jan 2003
Location: Dallas, TX
Distribution: Fedora Core 4
Posts: 420

Original Poster
Rep: Reputation: 30
I've heard that the nohup command (I think that's what it was called) does something similar to that. Gotz any info on that?

EDIT: "that" = starting a process so that it is NOT a child of the shell.
 
  


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
Install my basic Linux stuff--Linspire 4 lectraplayer Linux - Software 13 07-10-2005 08:46 PM
When installing new stuff in suse 9.1, do you uninstall old stuff first? randon SUSE / openSUSE 1 12-25-2004 04:37 PM
Basic security stuff mymojo Linux - Security 9 11-26-2003 11:49 AM
Basic shell stuff drsanchez Linux - General 10 05-28-2003 12:49 PM
I'm a BASIC chap, looking for some info on BASIC programming CragStar Programming 2 01-21-2001 09:19 AM


All times are GMT -5. The time now is 10:20 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