LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-18-2004, 03:35 AM   #1
obashir
LQ Newbie
 
Registered: Nov 2002
Location: Loughborough, UK
Distribution: Redhat 9, Fedora, Yellow Dog
Posts: 29

Rep: Reputation: 15
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?
 
Old 10-18-2004, 03:11 PM   #2
viniosity
Member
 
Registered: Oct 2001
Location: Washington, DC
Distribution: Debian, Archlinux, Ubuntu, Sidux
Posts: 244

Rep: Reputation: 30
maybe you can use screen in conjunction w/ ssh?
 
Old 10-18-2004, 04:13 PM   #3
nifflerX
Member
 
Registered: Dec 2003
Distribution: RedHat 8.0, 7.1 and Enterprise WS 3,4
Posts: 94

Rep: Reputation: 16
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
 
Old 10-19-2004, 03:46 AM   #4
obashir
LQ Newbie
 
Registered: Nov 2002
Location: Loughborough, UK
Distribution: Redhat 9, Fedora, Yellow Dog
Posts: 29

Original Poster
Rep: Reputation: 15
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
 
Old 11-16-2004, 09:27 PM   #5
mattfr
LQ Newbie
 
Registered: Nov 2004
Posts: 7

Rep: Reputation: 0
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
 
Old 11-17-2004, 08:27 AM   #6
pld
Member
 
Registered: Jun 2003
Location: Southern US
Distribution: Ubuntu 5.10
Posts: 206

Rep: Reputation: 30
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!
 
Old 11-17-2004, 12:03 PM   #7
viniosity
Member
 
Registered: Oct 2001
Location: Washington, DC
Distribution: Debian, Archlinux, Ubuntu, Sidux
Posts: 244

Rep: Reputation: 30
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
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh-agent, ssh-add and ssh-keygen AND CVS raylpc Linux - General 2 11-19-2008 02:50 AM
is ssh needed shanenin Linux - Security 5 11-09-2003 07:37 PM
No password needed for ssh or rsh wanted. syrtsardo Linux - Networking 6 11-04-2003 09:14 PM
Super Genius Needed: SuSEfirewall2 HELP with ssh and internal network and router ash0573 Linux - Networking 8 05-01-2003 05:20 PM
a little help with ssh needed :) saturn_vk Linux - Networking 6 03-16-2003 08:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:04 AM.

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
Open Source Consulting | Domain Registration