![]() |
HowTo.KeepRemoteConsoleSessionRunning HistoryHide minor edits - Show changes to markup June 13, 2008, at 06:44 PM
by -- dtach src updated Jan 30, 2008 (0.8) - last update 2004 (0.7)
Changed lines 135-136 from:
to:
May 06, 2008, at 04:24 PM
by -- formatting
Changed lines 246-250 from:
1. ssh to the slug as per normal. 2. $ ftp ftp.desired.server.org 3. Navigate to the desired area and get or mget the file(s) you want, this will start the download. 4. Type <CTRL>z 5. It should say something like: to:
Changed lines 252-253 from:
6. $ bg 1 - this starts the process in the background 7. It should say something like: to:
Changed lines 256-258 from:
8. Type ls -al a few times to ensure that the file you are downloading is getting bigger over time. If it is, it's working! 9. Exit your ssh session. If you like, you can ssh back in again to try step 8. just to ensure that it's working. to:
April 25, 2008, at 10:54 PM
by -- A tip to quickly and easily running ftp in the background.
Added lines 241-265:
In the bit where it says:
I'd like to share how I use the slug to download large files via ftp so that I don't have to have my main computer on. 1. ssh to the slug as per normal. 2. $ ftp ftp.desired.server.org 3. Navigate to the desired area and get or mget the file(s) you want, this will start the download. 4. Type <CTRL>z 5. It should say something like: [1]+ Stopped ftp ftp.desired.server.org 6. $ bg 1 - this starts the process in the background 7. It should say something like: [1]+ ftp ftp.desired.server.org & 8. Type ls -al a few times to ensure that the file you are downloading is getting bigger over time. If it is, it's working! 9. Exit your ssh session. If you like, you can ssh back in again to try step 8. just to ensure that it's working. If you need to kill the ftp process for whatever reason, list all processes via: ps -ax If the ftp is running and shouldn't be, killall ftp or if it's not responding, killall -9 ftp February 24, 2008, at 11:15 AM
by --
Changed lines 218-219 from:
to:
February 24, 2008, at 11:13 AM
by --
Changed lines 218-219 from:
to:
January 27, 2008, at 11:16 AM
by -- moved \"-z\" in the dtach command lines, as the socket path has to immediately follow \"-A\"
Changed lines 92-93 from:
dtach -A -z /tmp/mydtachsocket bash to:
dtach -A /tmp/mydtachsocket -z bash Changed line 100 from:
to:
Changed lines 106-107 from:
You can try it out on from a couple of terminals on the same workstation without having to change permission, it's freaky cool. Just to:
You can try it out on from a couple of terminals on the same workstation without having to change permission, it's freaky cool. Just Changed lines 110-111 from:
dtach -c -z /tmp/bgdtach myscript to:
dtach -c /tmp/bgdtach -z myscript November 17, 2007, at 05:15 PM
by -- bash disown
Changed line 2 from:
to:
Added lines 30-39:
bash disown$ help disown
disown: disown [-h] [-ar] [jobspec ...]
By default, removes each JOBSPEC argument from the table of active jobs.
If the -h option is given, the job is not removed from the table, but is
marked so that SIGHUP is not sent to the job if the shell receives a
SIGHUP. The -a option, when JOBSPEC is not supplied, means to remove all
jobs from the job table; the -r option means to remove only running jobs.
November 05, 2007, at 04:34 PM
by -- added article link on modifying screen status
Added lines 244-245:
September 26, 2007, at 04:22 AM
by -- cleaned up a typo, unescaped slash, and moved user example in to main screen section
Changed lines 84-85 from:
Then to detach from your session you could just close your terminal application or you can press the default Ctrl+ to:
Then to detach from your session you could just close your terminal application or you can press the default Ctrl+\ . Added lines 189-201:
Example one - Create a detached screen session. Then attach to it later (from User Contributions)The following screen command will create a new screen session: screen -dmS midnight mc
To attach to this screen, enter: Deleted line 243:
Deleted lines 245-253:
screen -dmS midnight mc
To attach to this screen, enter:
screen -R midnight
September 22, 2007, at 01:05 AM
by -- formatting
Changed lines 229-231 from:
to:
screen -AadR
Changed lines 234-237 from:
to:
screen -dmS midnight mc
Changed lines 242-244 from:
To attach to this screen, enter: to:
To attach to this screen, enter:
screen -R midnight
September 22, 2007, at 01:04 AM
by -- formatting
Changed lines 229-231 from:
screen -AadR to:
Changed lines 239-240 from:
screen -dmS midnight mc to:
September 22, 2007, at 01:03 AM
by -- formatting
Changed lines 15-16 from:
The nohup binary is normally included with even the most minimal unix like systems. With optware, slugos or debian, it's part of the coreutils package. to:
The nohup binary is normally included with even the most minimal unix like systems. With Optware, SlugOS or Debian, it's part of the coreutils package. Changed lines 234-239 from:
'-d -m' means: start screen in "detached" mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts. (So you can use this in /etc/rc.local to run anything in the background) '-S midnight' means: sets the screen-name to 'midnight' (so if you're running multiple screens you can easily find and re-attacht to it, instead of guessing the screen number); 'mc' tell screen to start the command 'mc' (midnight commander, if you've installed it). to:
Changed line 241 from:
To attach to this screen, enter: screen -R midnight to:
To attach to this screen, enter: September 20, 2007, at 11:01 AM
by --
Changed lines 153-154 from:
And, what's probably more important: I've noticed screen slurping up a lot of memmory (up to 1MB if I've read the numbers correct), and because you'll be running a sh or bash inside it, that takes _another_ 400-500K for every window inside screen.. Be aware of this if you're planning to use this on small-memmory devices like the NSLU2. to:
What's probably more important: I've noticed screen slurping up a lot of memmory (up to 1MB if I've read the numbers correct), and because you'll be running a sh or bash inside it, that takes _another_ 400-500K for every window inside screen.. Be aware of this if you're planning to use this on small-memmory devices like the NSLU2. Changed lines 170-172 from:
Someone feel free to point to an article on how to build it. For Debian users, as root: apt-get install screen to:
Someone feel free to point to an article on how to build it from source. September 20, 2007, at 10:57 AM
by -- screen example
Changed line 237 from:
'-S midnight' means: sets the screen-name to 'midnight' (so if you're running multiple screens you can easily find and re-attacht to it); to:
'-S midnight' means: sets the screen-name to 'midnight' (so if you're running multiple screens you can easily find and re-attacht to it, instead of guessing the screen number); Changed line 242 from:
To attach to this screen, ener: screen -R midnight to:
To attach to this screen, enter: screen -R midnight September 20, 2007, at 10:55 AM
by -- screen memmory usage and screen run-in-background example
Changed lines 152-153 from:
Unfortunately, you may end up with a hand cramp if you're managing several screen screens/tab at a time. Everything is Ctrl+Key CommandKey combo sequence. to:
Unfortunately, you may end up with a hand cramp if you're managing several screen screens/tab at a time. Everything is Ctrl+Key CommandKey combo sequence. And, what's probably more important: I've noticed screen slurping up a lot of memmory (up to 1MB if I've read the numbers correct), and because you'll be running a sh or bash inside it, that takes _another_ 400-500K for every window inside screen.. Be aware of this if you're planning to use this on small-memmory devices like the NSLU2. Changed lines 170-171 from:
to:
For Debian users, as root: apt-get install screen Added lines 176-182:
It will start screen, load a shell and drop you into it. You can exit it by exiting the shell (just type 'exit', and screen will close too). You can detach it by pressing Ctrl+A D You'll be returned to the non-screened shell, and the process running in screen will continue running in the background. To re-attach to a screen session, enter: screen -R You'll return to your screen session jus where you left it. (however, if there's more than one screen running then it will give you a list of screens to attach to) Inside the 'screen', there are various commands you can use: Added lines 233-242:
'-d -m' means: start screen in "detached" mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts. (So you can use this in /etc/rc.local to run anything in the background) '-S midnight' means: sets the screen-name to 'midnight' (so if you're running multiple screens you can easily find and re-attacht to it); 'mc' tell screen to start the command 'mc' (midnight commander, if you've installed it). screen -dmS midnight mc To attach to this screen, ener: screen -R midnight September 19, 2007, at 03:14 PM
by -- formatting
Changed lines 220-222 from:
to:
screen -AadR September 19, 2007, at 03:13 PM
by -- screen -AadR
Added lines 198-199:
Changed lines 219-222 from:
to:
September 19, 2007, at 03:10 PM
by -- added horizontal bars
Added line 6:
Added line 36:
Added lines 143-144:
September 19, 2007, at 03:08 PM
by -- nohup part of coreutils
Changed lines 14-15 from:
Someone can update this section, but nohup is normally included with even the most minimal unix like systems. to:
The nohup binary is normally included with even the most minimal unix like systems. With optware, slugos or debian, it's part of the coreutils package. September 19, 2007, at 01:41 PM
by -- formatting
Changed line 89 from:
to:
September 19, 2007, at 01:40 PM
by -- formatting, typos
Changed lines 9-10 from:
nohup is a command preventing the subsequent executing command from receiving some system Signals such as as HANGUP - hence NOHUP = no hangup. It's commonly used with the shell's standard job control since the execution will still occupy the executing prompt, for example, the ampersand to background a task. By default, all the stdout console output is redirected to nohup.out unless you redirect it yourself. to:
nohup is a command preventing the subsequent executing command from receiving some system Signals such as HANGUP - hence NOHUP = no hangup. It's commonly used with the shell's standard job control since the execution will still occupy the executing prompt, for example, the ampersand to background a task. By default, all the stdout console output is redirected to nohup.out unless you redirect it yourself. Changed lines 53-54 from:
If you are using Optware, just issue the command: ipkg install dtach to:
If you are using Optware, just issue the command: Changed line 56 from:
to:
Changed lines 59-60 from:
If you're using Debian, `apt-get install dtach` will install it to:
If you're using Debian, Changed lines 80-81 from:
dtach -A -z /tmp/mydtachsocket bash to:
dtach -A -z /tmp/mydtachsocket bash Changed lines 88-93 from:
1. dtach -A -z /tmp/myvisession vi log-or-filename 2. in vi, issue the command - : !chmod 660 /tmp/myvisession # (NOTE: I couldn't get 640 to work for me) 3. have your all your peers connect using: dtach -a /tmp/myvisession # now everyone can work the file or log to:
Changed lines 94-95 from:
You can try it out on from a couple of terminals on the same workstation without having to change permission, it's freaky cool. Just `dtach -A -z /tmp/mydtachsocket bash` in multipleconsoles. to:
You can try it out on from a couple of terminals on the same workstation without having to change permission, it's freaky cool. Just Changed lines 98-101 from:
dtach -c -z /tmp/bgdtach myscript make sure your script or command redirects it's output someplace else for review. It doesn't cache stdout & stderr for you. You would have to attach to see them if not captured. to:
dtach -c -z /tmp/bgdtach myscript Make sure your script or command redirects it's output someplace else for review. It doesn't cache stdout & stderr for you. You would have to attach to see them if not captured. Changed line 106 from:
to:
Changed line 110 from:
to:
Changed line 127 from:
to:
Changed lines 132-133 from:
to:
Changed line 137 from:
to:
Changed lines 139-140 from:
to:
Changed lines 148-153 from:
Unfortunately, you may end up with a hand cramp if you're managing several screen screens/tab at a time. Everything is Ctrl+Key CommandKey? combo sequence. Installation ( much like dtach )If you are using Optware, just issue the command: ipkg install screen to:
Unfortunately, you may end up with a hand cramp if you're managing several screen screens/tab at a time. Everything is Ctrl+Key CommandKey combo sequence. Installation (much like dtach)If you are using Optware, just issue the command: Changed line 155 from:
to:
Changed lines 158-159 from:
If you're using Debian, `apt-get install screen` will install it to:
If you're using Debian, Changed lines 170-171 from:
To create a new screen, press Ctrl+A C . You can do this any number of times. to:
To create a new screen, press Ctrl+A C. You can do this any number of times. Changed lines 186-187 from:
to:
Changed line 191 from:
to:
Added line 195:
September 19, 2007, at 08:37 AM
by --
Changed lines 192-195 from:
http://en.wikipedia.org/wiki/GNU_Screen - lists official site, and other resources http ://www.linuxmanpages.com/man1/screen.1.php http://www.linuxjournal.com/article/6340 to:
September 19, 2007, at 08:36 AM
by --
Changed lines 22-23 from:
ps -fu username # will show your processes not attached to any shell. Important for tracking down nohup processes to kill. to:
ps -fu username # will show your processes not attached to any shell.
# Important for tracking down nohup processes to kill.
September 19, 2007, at 08:34 AM
by --
Deleted line 1:
Changed lines 18-23 from:
nohup cmd & # stdout is redirected to nohup.out nohup cmd > std.out 2> std.err & ps -fu username # will show your processes not attached to any shell. Important for tracking down nohup processes to kill. to:
nohup cmd & # stdout is redirected to nohup.out nohup cmd > std.out 2> std.err & ps -fu username # will show your processes not attached to any shell. Important for tracking down nohup processes to kill. Deleted line 28:
Changed lines 68-69 from:
to:
Changed lines 88-92 from:
2. in vi, issue the command - : !chmod 660 /tmp/myvisession (NOTE: I couldn't get 640 to work for me) 3. have your all your peers connect using: dtach -a /tmp/myvisession now everyone can work the file or log to:
2. in vi, issue the command - : !chmod 660 /tmp/myvisession # (NOTE: I couldn't get 640 to work for me) 3. have your all your peers connect using: dtach -a /tmp/myvisession # now everyone can work the file or log Deleted line 155:
September 19, 2007, at 08:30 AM
by --
Changed line 37 from:
-- to:
September 19, 2007, at 08:30 AM
by --
Added lines 143-217:
screen (GNU screen)About GNU screenWhat's there to say? It's the granddaddy of screen multiplexers. It was written years ago in the age of dial-up to allow multiple consoles over a single terminal connection. It's still being actively developed and advanced today. dtach is a 1-to-1 session manager. Screen takes over terminal management. It's highly configurable. Instead of re-hashing the many articles on screen, you can check out some links at the end of this post. And yes, screen allows you to share screen with others. It's a switch and managed differently than dtach. Unfortunately, you may end up with a hand cramp if you're managing several screen screens/tab at a time. Everything is Ctrl+Key CommandKey? combo sequence. Installation ( much like dtach )If you are using Optware, just issue the command: ipkg install screen If you are using SlugOS, you have two options:
If you're using Debian, `apt-get install screen` will install it If you're using a major distro on your desktop, it should be found in your distro's repository Building and InstallationSomeone feel free to point to an article on how to build it. UsageSimply invoke: screen To create a new screen, press Ctrl+A C . You can do this any number of times. To switch between screens, press Ctrl+A #, where # is 0 through 9. To close a screen, just log out. Note, just because you close 2, doesn't shift 3, 4 & 5 down. #2 is freed up, that's all. Gotchas and idiosyncrasies(there's more than this)
Tips and Suggestions
Additional Referenceshttp://en.wikipedia.org/wiki/GNU_Screen - lists official site, and other resources http ://www.linuxmanpages.com/man1/screen.1.php http://www.linuxjournal.com/article/6340 User Contributed Tips, Examples, URL references, etc.The wall of shame. Feel free to shout out your tips and examples here so we can keep the above article from having 50 tips and examples in each section. Thanks. nohupnohup TipsHow I use nohupdtachdtach TipsHow I use dtachscreenscreen TipsHow I use screenSeptember 19, 2007, at 08:29 AM
by --
Changed line 141 from:
to:
September 19, 2007, at 08:28 AM
by --
Added lines 139-142:
September 19, 2007, at 08:28 AM
by --
Added lines 35-138:
dtach-- About dtachdtach originated as a minimalist alternative to screen. It allows you to spawn a shell or other command into its own detachable pseudo-terminal. It also allows you the ability to share your session with a cohort. It can be used anywhere from large corporate style servers to the lovable NSLU2 Slugs.
Now, you can return to interactive session of `mc`, Vim, or a compile, etc. no sweat. (Try a long compile on the Slug?) In fact, this is probably the most extensive article you'll come across about using dtach. Most people use screen before realizing dtach is just enough - that is if they find out about dtach at all. InstallationIf you are using Optware, just issue the command: ipkg install dtach If you are using SlugOS, you have two options:
If you're using Debian, `apt-get install dtach` will install it If you're using a major distro on your desktop, it should be found in your distro's repository Building and InstallationIf you want to compile, package and install your own version (untried for Slug)
the build on a regular RHES Linux box for personal use was: ./configure; make; strip dtach; cp dtach ~/bin ; # as not to pollute the /usr/bin or /usr/local/bin system using `sudo make install` UsageExample one - a standard, detachable Bash sessionThis example launches a dtach session. If the unix socket exists, attach to it, otherwise create a new session/socket and execute bash. dtach -A -z /tmp/mydtachsocket bash Then to detach from your session you could just close your terminal application or you can press the default Ctrl+ Example two - a sharable Bash sessionSay you don't care about a detachable session, but you want to share a Vi session with a co-worker in the same user group. No problem. 1. dtach -A -z /tmp/myvisession vi log-or-filename 2. in vi, issue the command - : !chmod 660 /tmp/myvisession (NOTE: I couldn't get 640 to work for me) 3. have your all your peers connect using: dtach -a /tmp/myvisession now everyone can work the file or log Now both you and you co-worker can work together on the same file, seeing the same thing. The best part is, you don't have to restart your session - instant gratification - if you start out using dtach. You can try it out on from a couple of terminals on the same workstation without having to change permission, it's freaky cool. Just `dtach -A -z /tmp/mydtachsocket bash` in multipleconsoles. Example three - backgrounding like nohupdtach -c -z /tmp/bgdtach myscript make sure your script or command redirects it's output someplace else for review. It doesn't cache stdout & stderr for you. You would have to attach to see them if not captured. Other Examples or situationsThis list could be really long. It's up to you to try some out. Please add your suggestions and ideas at the end of the page. Many of these are applicable to screen as well.
Gotchas and idiosyncrasies
Tips and Suggestions
Additional ReferencesSeptember 19, 2007, at 08:26 AM
by --
Deleted lines 0-1:
Changed lines 31-34 from:
http://en.wikipedia.org/wiki/Nohup http://www.idevelopment.info/data/Unix/General_UNIX/GENERAL_RunningUNIXCommandsImmunetoHangups_nohup.shtml http://www.computerhope.com/unix/unohup.htm http://www.google.com/search?q=nohup+example&btnG=Search&hl=en to:
September 19, 2007, at 08:25 AM
by --
Added lines 8-36:
nohup and Standard job controlAbout nohupnohup is a command preventing the subsequent executing command from receiving some system Signals such as as HANGUP - hence NOHUP = no hangup. It's commonly used with the shell's standard job control since the execution will still occupy the executing prompt, for example, the ampersand to background a task. By default, all the stdout console output is redirected to nohup.out unless you redirect it yourself. This is fine for most situations not requiring user interaction or response. Building and InstallationSomeone can update this section, but nohup is normally included with even the most minimal unix like systems. Usage examplesnohup cmd & # stdout is redirected to nohup.out nohup cmd > std.out 2> std.err & ps -fu username # will show your processes not attached to any shell. Important for tracking down nohup processes to kill. Tips and Suggestions
Additional Referenceshttp://en.wikipedia.org/wiki/Nohup http://www.idevelopment.info/data/Unix/General_UNIX/GENERAL_RunningUNIXCommandsImmunetoHangups_nohup.shtml http://www.computerhope.com/unix/unohup.htm http://www.google.com/search?q=nohup+example&btnG=Search&hl=en September 19, 2007, at 08:24 AM
by -- adding new howto - KeepRemoteConsoleSessionRunning for nohup, dtach and screen
Changed lines 1-7 from:
Place holder to:
KeepRemoteConsoleSessionRunningThere are many different reasons and situations you may want to keep your current terminal activity or execution running. Luckily, there are more than one way of managing the process or application.
September 19, 2007, at 08:23 AM
by -- initial creation on using nohup, dtach and screen
Added line 1:
Place holder
view ·
edit ·
print ·
history ·
Last edited by MarkStinson.
Based on work by BrianZhou, Fred, bla, asdf, MarkStinson, markstinson, fcarolo, and cbase. Originally by markstinson. Page last modified on June 13, 2008, at 06:44 PM
|