Good day, I have a centos 4.4 box (all yumed up).
Now i have a program that has a sub shell - meaning something like the mysql command line, where once started it takes it's own commands, etc and keeps running until a "quit" command is issued. Now what I was wondering - is there a way to fork it to the background (something like # command & or ctrl -z) and have the subshell keep running? And also to be able to get back to the sub shell?
For example, if i do run it with the & at the end it does what I want, yet obviously (to my knowledge) you can't get back to the subshell without killing it and restarting it. I have looked into the "screen" shell utility, which for the most part does what I needed, however after a few days the session had disappeared and I was not able to get back to it from another machine/ssh session.
Are there any other options?
Thanks!
Dustin
For example, if i do run it with the & at the end it does what I want,
yet obviously (to my knowledge) you can't get back to the subshell without killing it and restarting it. I have looked into the "screen" shell utility, which for the most part does what I needed, however after a few days the session had disappeared and I was not able to get back to it from another machine/ssh session.
Are there any other options?
screen works pretty well, I have some screen sessions that are more than month old. When you connect from antoher machine, what command do you type? It should be:
screen -r -x
That forces a reconnect, even if someone else is already connected.
On a side note: this is a nice way to collaborate on some work between a few people who are not at the same physical location. Everyone SSH's in to a machine, one person runs screen, the others run screen -r -x. you are now all staring at the same terminal and can all work together. Handy for teaching people.
Cheers, Mike
On 12/12/06, mike.redan@bell.ca mike.redan@bell.ca wrote:
For example, if i do run it with the & at the end it does what I want,
yet obviously (to my knowledge) you can't get back to the subshell without killing it and restarting it. I have looked into the "screen" shell utility, which for the most part does what I needed, however after a few days the session had disappeared and I was not able to get back to it from another machine/ssh session.
Are there any other options?
screen works pretty well, I have some screen sessions that are more than month old. When you connect from antoher machine, what command do you type? It should be:
screen -r -x
That forces a reconnect, even if someone else is already connected.
On a side note: this is a nice way to collaborate on some work between a few people who are not at the same physical location. Everyone SSH's in to a machine, one person runs screen, the others run screen -r -x. you are now all staring at the same terminal and can all work together. Handy for teaching people.
Cheers, Mike
Ah ok, the tutorial I had read said screen -R upon reconnecting. I will try your way and test it further.
Good note for the shared sessions too!
Dustin
Dustin Krysak wrote:
On 12/12/06, mike.redan@bell.ca mike.redan@bell.ca wrote:
screen works pretty well, I have some screen sessions that are more than month old. When you connect from antoher machine, what command do you type? It should be:
screen -r -x
That forces a reconnect, even if someone else is already connected.
It took me about 10 years of using unix in general before I learned about screen and I sorely regret not having learning about it sooner. I've been using screen for about three years now and I just can't do without it.
I totally encourage everyone to learn screen. It's so very worth it. I encourage you to google for "intitle:.screenrc" and find out how to turn on Nethack Mode in screen, next!
Jed
On 12/16/06, Jed Reynolds lists@benrey.is-a-geek.net wrote:
It took me about 10 years of using unix in general before I learned about screen and I sorely regret not having learning about it sooner. I've been using screen for about three years now and I just can't do without it.
I used screen almost exclusively for several years a long time ago and was very happy with it. I still use it when connecting with ssh from my PDA because it's text-only and the connection is unreliable. Most of the time, though, I use VNC or FreeNX so I can dis/re-connect my entire X desktop; it's just not worth it to mess around on the level of individual terminals.
There's also something called retty (http://pasky.or.cz/~pasky/dev/retty/, available from rpmforge) that I haven't really tried out much yet, that lets you interact with a process that's running on a different tty device. That doesn't help if the first tty has actually hung up, and it seems to be tricky to get it to work right even on simple processes.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Tue, Dec 12, 2006 at 09:56:59AM -0800, Dustin Krysak wrote:
I have looked into the "screen" shell utility, which for the most part does what I needed, however after a few days the session had disappeared and I was not able to get back to it from another machine/ssh session.
Are there any other options?
If I recall correctly, screen will create session data files on /tmp. tmpwatch or some other utility might be removing those, and that is why you are "loosing" your sessions.
You might want to take a look at the SCREENDIR environment variable, and specify some different directory where your sockets will be safer.
[]s
- -- Rodrigo Barbosa "Quid quid Latine dictum sit, altum viditur" "Be excellent to each other ..." - Bill & Ted (Wyld Stallyns)
Am Dienstag, 12. Dezember 2006 18:56 schrieb Dustin Krysak:
For example, if i do run it with the & at the end it does what I want, yet obviously (to my knowledge) you can't get back to the subshell
Type in "fg" which means foreground. Also works for jobs suspended with "Ctrl-Z". "bg" can be used to put jobs suspended with "Ctrl-Z" into the background (as if run with &).
Googling for "job control" could help. I would also suggest reading a UNIX/Linux Shell Tutorial. It's worth learning a few helpful commands to get your everyday shell work done quicker.
regards, Andreas Micklei
On Tue, 2006-12-12 at 19:43 +0100, Andreas Micklei wrote:
Am Dienstag, 12. Dezember 2006 18:56 schrieb Dustin Krysak:
For example, if i do run it with the & at the end it does what I want, yet obviously (to my knowledge) you can't get back to the subshell
Type in "fg" which means foreground. Also works for jobs suspended with "Ctrl-Z". "bg" can be used to put jobs suspended with "Ctrl-Z" into the background (as if run with &).
Googling for "job control" could help. I would also suggest reading a UNIX/Linux Shell Tutorial. It's worth learning a few helpful commands to get your everyday shell work done quicker.
Googling? Do man bash and read up on job control.
regards, Andreas Micklei
<snip sig stuff>
-- Bill
William L. Maltby wrote:
On Tue, 2006-12-12 at 19:43 +0100, Andreas Micklei wrote:
Am Dienstag, 12. Dezember 2006 18:56 schrieb Dustin Krysak:
For example, if i do run it with the & at the end it does what I want, yet obviously (to my knowledge) you can't get back to the subshell
Type in "fg" which means foreground. Also works for jobs suspended with "Ctrl-Z". "bg" can be used to put jobs suspended with "Ctrl-Z" into the background (as if run with &).
Googling for "job control" could help. I would also suggest reading a UNIX/Linux Shell Tutorial. It's worth learning a few helpful commands to get your everyday shell work done quicker.
Googling? Do man bash and read up on job control.
Do you really suggest that to a beginner with no prior knowledge of job control? The bash manpage contains way to much detail information that you really don't want to know when playing around with fg and bg for the first time. It's a great reference when you already know the basics and want to learn about the details, but heavy reading for a beginner.
regards, Andreas Micklei
On Sat, 2006-12-16 at 00:15 +0100, Andreas Micklei wrote:
William L. Maltby wrote:
On Tue, 2006-12-12 at 19:43 +0100, Andreas Micklei wrote:
Am Dienstag, 12. Dezember 2006 18:56 schrieb Dustin Krysak:
For example, if i do run it with the & at the end it does what I want, yet obviously (to my knowledge) you can't get back to the subshell
Type in "fg" which means foreground. Also works for jobs suspended with "Ctrl-Z". "bg" can be used to put jobs suspended with "Ctrl-Z" into the background (as if run with &).
Googling for "job control" could help. I would also suggest reading a UNIX/Linux Shell Tutorial. It's worth learning a few helpful commands to get your everyday shell work done quicker.
Googling? Do man bash and read up on job control.
Do you really suggest that to a beginner with no prior knowledge of job control?
Yes! Most certainly. See below.
The bash manpage contains way to much detail information that you really don't want to know when playing around with fg and bg for the first time. It's a great reference when you already know the basics and want to learn about the details, but heavy reading for a beginner.
Agreed. But I may have a failing that others do not. I have faith that if they are installing CentOS, doing networking, ... they have both the intelligence and initiative to undertake learning complex software configuration and coding constructs. Each also has the innate ability to judge when they need to ask for help or search on the web for it, in my estimation.
This may be a failing of my having learned shell programming without the aid of teachers, tutorials or anything other than a man page. Yes, I stumbled. Going was initially slow. But I fell my depth of learning and expertise was increased by my effort. I just wish I had been so astute when major enhancements were introduced instead of having to swallow all the changes in one big gulp.
regards, Andreas Micklei
I'm a strong believer in the ability of the individual and am against spoon-feeding as the first step in learning. It stifles creativity, reduces the "imprinting" of knowledge that comes with "learning the hard way" and makes dependents of potential independents. I guess I'm just too "old school" for today's attitudes.
<snip sig stuff>
MO -- Bill