LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-15-2010, 08:38 PM   #1
lawson
LQ Newbie
 
Registered: Dec 2009
Posts: 9

Rep: Reputation: 0
run commands persistently over ssh


I would like to log in to a remote machine via SSH, start a process running, and then log out, leaving the remote process running. This seems like an obvious thing to do, but I can't figure out how to do it! The problem is that any process that I start seems to be "attached" (sorry, I don't really know the correct terminology here) to my SSH login shell, and so when I log out the process is killed. Ctrl+Z bg doesn't seem to do it, either. Is there a way to do this? It seems that there must. Thanks!
 
Old 02-15-2010, 08:53 PM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
You can use nohup to start a command that will not hangup when the shell exits. In this example, output goes to output.log, errors to error.log:
Code:
nohup foo >output.log 2>error.log &
You can use the bash command disown to do the same thing with an existing process, eg:
Code:
foo >output.log 2>error.log &
disown
Or you can use GNU screen to create a terminal that can be disconnected/reconnected at will.

Last edited by neonsignal; 02-15-2010 at 09:21 PM.
 
1 members found this post helpful.
Old 02-16-2010, 05:21 AM   #3
talla
LQ Newbie
 
Registered: Jan 2010
Location: Berlin
Posts: 16

Rep: Reputation: 1
screen is very nice.

just type "screen". A "shell in shell" will open. Start your process, then press Strg + ALT + D to detach your screen and return to your "usual shell".

When you log in again use "screen -r" to switch back to you running process.

(you can even start multiple shells in screen using Strg + A + C and switch between them using Strg + A + N)

And moreover, you can share a screen with other users for remote interaction
http://www.linux.com/archive/feed/56443

Cheers,
talla

Last edited by talla; 02-16-2010 at 05:52 AM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to ssh as root to a workstation and then run commands as another user. martinhb Linux - Security 5 06-10-2009 10:04 PM
How to write a script with auto login ssh and then run commands? keber314 Linux - Server 13 02-16-2009 03:37 PM
How to run a set of commands through ssh vickylife Linux - Newbie 8 11-13-2008 06:48 PM
getting SSH commands to run as local r00tb33r Linux - Software 2 02-02-2008 11:58 PM
LXer: Run Parallel Commands in a Cluster Using SSH on UNIX LXer Syndicated Linux News 0 09-12-2006 01:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:22 PM.

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