Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Consider the following nohup execution:

nohup script.sh > script.out &

Is there a way to log off the terminal, reconnect, bring the process back to foreground and interact with it using the keyboard?

share|improve this question

3 Answers 3

up vote 4 down vote accepted

If you wanted to start a script, have it run without the output bothering your terminal and then bring it up later to interact with it, you might want to take a look at the screen command. You can find some info on how to use it in the pages below:

share|improve this answer
    
+1 Excellent tool I didn't know of. Many thanks. –  Adam Matan Aug 17 '11 at 16:36

I'll second the use of a terminal multiplexer, but tmux, not screen. Screen is, for all intents and purposes, unmaintained. Its configuration is a dark art, likely first recorded in an appendix of the Necronomicon. Attempting to write your own config is as a glimpse of Cthulu. Seriously. Look around at people's .screenrc files. To be sure, there are ways to mediate screen's abomination of a config flle. Byobu does an admirable job as the veil between mortal users and unholy code. It comes with sensible colours, a menu interface, and perhaps most importantly, a status bar.

But as I said, I recommend tmux instead. It still requires some minor configuration, but it is well documented, and your config file won't look like gibberish. Also, you start out with colours and a status bar. Compare my screenrc and tmux.conf files:

share|improve this answer

If you are just interested in looking live hat the output this might suit you:

nohup script.sh 2>&1 script.out &
# later:
tail -f script.out
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.