3

I have ssh'd into a ubuntu AWS box via terminal on mac. I have successfully setup the process I want to run in the box.

How do can exit out of terminal without killing the process running?

Can not run the below command because terminal is running the script and not allowing me to even copy and paste the below command into terminal:

nohup long-running-process &

Thank you in advance.

P.S

New to linux and terminal on mac

4
  • If you have already started the script, background and disown it: unix.stackexchange.com/a/23623/70524 Commented Feb 6, 2018 at 5:35
  • Hi @muru I am trying this method: end processName to the background with bg %1 (using whatever the job # is following the %). This will resume processName in the background. but I am getting error 'Failed to open config file bg' Commented Feb 6, 2018 at 5:46
  • Is your process already in the background? If not, go to the step before that. Commented Feb 6, 2018 at 5:47
  • Note that in the suggested duplicate, the answers other than the accepted one are definitely better solutions if you can prepare before starting the long-running process.. Commented Feb 7, 2018 at 0:08

2 Answers 2

8

ersonally I use screen to get in/out of the system while keeping the processes running.

$ sudo apt install screen

To create a new screen:

$ screen -S screen_name

Then do something in your screen, for example running a program, editing files, downloading file with wget, etc.

Later if you want to exit the terminal without killing the running process, simply press Ctrl+A+D. The process will kept running in the background inside the screen

To reconnect to the screen:

$ screen -R screen_name
2

Stop process with ctrl+z, put it in Background with bg, detach from shell with disown - exit shell.

Better use a multiplexer like screen https://help.ubuntu.com/community/Screen if you run into that more often.

4
  • confirming, I ran your three commands above got the message. "-bash: warning: deleting stopped job 3 with process group 10461" does that mean process is still running in background? Commented Feb 6, 2018 at 5:58
  • 1
    @RustyShackleford that most probably means that the process was killed and no longer running. You'd better use screen indeed. Just learn 2 commands and 2 shortcuts and it will become trivial. Commented Feb 6, 2018 at 7:20
  • @ddnomad the screen worked! Posting answer below! Commented Feb 6, 2018 at 12:41
  • ctrl+z worked! I'm just wondering why would they choose ctrl+z instead of ctrl+c or ctrl+d. Like every program is starting to have its own way of exiting the terminal while its running. Commented May 20, 2019 at 2:46

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.