PDA

View Full Version : need a little linux help



FoBoT
04-23-2004, 12:57 PM
i can generally follow directions when dealing with linux, so i am looking for some directions

i am putting a small distro (clarkconnect) onto some boxen to run Eon. it contains an SSH presetup to get onto the command line of the box via java from my windows machines.

when i setup a linux/Eon box with a monitor/keyboard, i just do a shift-F2 , logon to the console, get to the Eon directory and run ./client

for these new boxen, i want to run them headless. so i need to SSH in and start the client or SSH in and get the client to run automagically/all the time

if i start the ./client like i do from the console in the SSH session, i have to keep it open (right?) , so how can i set it up to keep running ?

hope this makes sense :blush:

Bok
04-23-2004, 01:54 PM
3 options

1. just pipe it to background

./client &



the following 2 involve using the program

screen

2. install screen on the boxes in question
then
ssh user@box
screen
cd /eon
./client
CTRL-A,D (i.e. CTRL-A, release, then D)

then you can exit out

3. install screen on the box you are sshing from

almost the same but run screen before the ssh



screen comes as part of most distros, the advantage of 1 over 2 is that ssh does use up some resource doingthe encrytion of the output, though you could pipe it all to /dev/null for each client

the first option will cause the shell to crap out when exiting ssh, anyone know how to get around this??? It's nt a problem though.

Bok

alpha
04-23-2004, 03:41 PM
Originally posted by Bok
the first option will cause the shell to crap out when exiting ssh, anyone know how to get around this??? It's nt a problem though.

What do you mean by 'crap out'?

If I want a process to continue to run after I logout (and I do not want to use screen), I use nohup.

FoBoT
04-23-2004, 03:45 PM
i remember seeing that in other posts about stuff like this, the nohup thing

so what would be the line i type?

inside my SSH window on my command line, i type

nohup ./client

or something?

then i can close the SSH session and it will continue to run?

alpha
04-23-2004, 03:59 PM
I haven't used it for a while, but


nohup ./client &

should do it.

I use a feature of my shell (zsh), to put things into the background permanently:


./client &!

which works real well.

Either way, the client should continue to run while you are logged out of the system. In the case of nohup, it outputs client output to nohup.out.

Bok
04-23-2004, 04:09 PM
yeah you don't really need nohup as the client outputs to its own file anyway.

so just

./client &

the & means run in background.

not really used zsh for a long time (pre-bash) so I haven't seen the ! before.

If you have put something in background on an ssh session,then when you exit out (CTRL-D/exit) the original terminal session is stuck. I've been too lazy to investigate what is going on. It's probably something stupid. But you can just kill the window.

Bok

alpha
04-23-2004, 04:13 PM
Maybe our different choice of shells is why I am having different results. zsh seems to behave slightly differently. If I start an application with &, it keeps the job running in the background until the user logs off (or the shell is killed, whatever). To keep the job running after logoff, I have to use nohup, or &!.

I'm sure our resident *nix guru will pop by and clear this up for us. ;)

magnav0x
04-23-2004, 04:20 PM
Even though the client outputs to it's on file it's safer to use nohup any how. I've seen some applications have problems with ./client &.

To be safe I would use:

nohup ./client &

Log out then log back in and throw a ps aux and if all went well you should see the process.

FoBoT
04-23-2004, 04:39 PM
thanks for all the responses, this makes sense :cheers:

magnav0x
04-23-2004, 04:46 PM
BTW, alpha is correct by using & it will put the process in the background. As soon as the user logs out of that shell it will immediatly be killed. nohup is typicaly the standard to use without going into advanced stuff.

A bit of an example of what nohup actualy does:

nohup ./client &
is the same as
./client > nohup.out &


The nohup command will automatically send all out put to nohup.out. In addition it runs the program as a service (not too sure on the details of exactly what it does to run it as a service though) which enables it to continue running after logged out. Usualy this is a perfect solution for those wanting to run something headless.