0

There are quite a few questions asking what you can do to run a shell script in the background while not running the terminal. Most have advised to use nohup or disown.

This might be a stupid question, but I am new to Linux and Ubuntu, but can anyone explain to me why not just press Ctrl + Alt + 1...6 to open a TTY (teletype terminal) and run the script appended with a &? Then I can just choose another TTY or the GUI to carry on whatever I am doing. I read here that I can even more TTYs (although the answer does not tell me how)

What are the pro's and con's of this approach over the 'commonly-accepted' (in SE it seems at least)

1

1 Answer 1

1

nohup literally means no hang up ie. make the process ignore closure of the terminal. If you do not use nohup, then your process will be killed when you close the terminal (logout).

& means run in background. Your key presses go to the foreground process. So if you use & the process you start will not get your key presses.

The downside of what you propose (to run each process on a spare terminal) is that you will run out of spare terminals. You might want to look into using screen, which enables you to create terminals dynamically (ctrl-a c). Then you can start every process in a different terminal. You can also make the scrollback buffer huge (eg. 5000 lines) so you can scroll back and see all of the log data without having to redirect it to files.

1
  • Thanks for clarifying! Your explanation of what the & actually does is really helpful! I will have a look at screen and scrollback buffer!
    – dayuloli
    May 31, 2014 at 15:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .