4

I started an installation process from a terminal and have two questions about this:

  1. How can I close the terminal without terminating the installation process? and how can I restore it again?
  2. How can I figure that this terminal has finished processing from another terminal so that I can do other processes based on the result of the first terminal?
muru
  • 197,895
  • 55
  • 485
  • 740
  • 1
    For 1, see http://askubuntu.com/q/106351/158442. There's no easy way to restore if you haven't used screen or tmux before starting the process. 2. Check whether the process is still running using pgrep, top or some other process monitoring tool. – muru Apr 14 '16 at 15:03
  • A similar question with various good answers and lots of votes can be found at https://unix.stackexchange.com/q/4004/163108 – davidovitch May 22 '22 at 07:51

1 Answers1

7

For 1. you need to send your running process to the background and remove the associated job from current shell.

  • Press Ctrl+Z and type bg to send the installation process to the backgroud
  • then type disown.

enter image description here

You can now close the terminal, the process will still be alive. You can open another terminal and check its process id with ps -aef

enter image description here

In my case the process id is 14426. Unfortunately there's no easy way to reattach it to another terminal (See How to attach terminal to detached process?) unless you used something based on screen.

For 2. You can use the following command:

while kill -0 14426 >/dev/null 2>&1; do sleep 5 ; done ; echo "ok"

It will print ok when the process is over from an other terminal. You can of course change this echo command with something more complex.

Source: BASH: launch background process and check when it ends