LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   SSH help needed (https://www.linuxquestions.org/questions/linux-general-1/ssh-help-needed-244077/)

obashir 10-18-2004 03:35 AM

SSH help needed
 
I'm trying to run a program via ssh remotely, however, I do not want the process to be tied to that login.

Does anyone know how I can run the process in such a way that when the session closes the program continues to execute?

viniosity 10-18-2004 03:11 PM

maybe you can use screen in conjunction w/ ssh?

nifflerX 10-18-2004 04:13 PM

Why can't you run the process in the background (with an &) at the end of the command line? If you do that the process should continue to run even after you have ended your ssh session. One note, if the process has some pop up displays or GUIs I don't know if this will work.


-NifflerX

obashir 10-19-2004 03:46 AM

Hi,

I was using putty on a windows machine to connect to a linux box. So doing

#./foo &

would run foo in the background but when I would close the putty window without typing exit on #, foo would abnormally terminate as well.

However, if I exit the session normally by typing exit on #, foo continues to run in the background and can be observed via ps -A on another putty window.

Thanks for the help

mattfr 11-16-2004 09:27 PM

Use the command 'at'

e.g.

% at -f batch.txt now

-f tells at to take the commands from a file, in this case batch.txt. 'now' tells at when to execute the command.

batch.txt contains the command that you want to execute, for example:

ls -l > junk.txt &

The & backgrounds the command execution and, as was mentioned, shouldn't involve any GUI or graphics. Run this, and you can log off, and the job should still run.

See 'man at' for details
----

however... a related question, why can't one run a backgrounded batch process involving graphics and simply redirect the graphics in some manner? I have a situation where I can't run a command in a certain software unless I send a gui command (which can actually be submitted in a text file). I also am using ssh and really must be able to background the process. I really don't need to see the menu pop open, I just want the command to run. Can anyone think of a way of redirecting the graphics, to /dev/null or something? (This isn't the same as redirecting stderr or stdout to /dev/null).

My eternal gratitude to the first person with a suitable answer!

Thanks and good luck,
Matt

pld 11-17-2004 08:27 AM

you really might wanna look into screen (as mentioned above). I have been using it for a year or so now to access my home machine through ssh, and to keep certain processes running after i log off. I come home, restore the screen, and i am off again without a single hitch!

viniosity 11-17-2004 12:03 PM

To use screen you would

1. ssh into your box
2. type screen -S foo
3. do whatever you want to do..
4. detach your screen before you move on by hitting ctrl-a and ctrl-d at the same time.
5. ssh into your box from somewhere else..
6. type screen -r foo to get back your screen


All times are GMT -5. The time now is 01:11 PM.