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?
2
  • 1
    For 1, see 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, 2016 at 15:03
  • A similar question with various good answers and lots of votes can be found at unix.stackexchange.com/q/4004/163108 May 22, 2022 at 7:51

1 Answer 1

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

0

You must log in to answer this question.

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