LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Really basic stuff here (https://www.linuxquestions.org/questions/linux-newbie-8/really-basic-stuff-here-147662/)

gauge73 02-18-2004 01:29 PM

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. :)

b0uncer 02-18-2004 01:40 PM

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?

gauge73 02-18-2004 01:44 PM

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?

Thymox 02-18-2004 06:52 PM

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.

b0uncer 02-19-2004 08:43 AM

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.

gauge73 02-19-2004 09:18 AM

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.


All times are GMT -5. The time now is 11:10 AM.