M BUZZ CRAZE NEWS
// news

close the terminal without terminating the process

By Jessica Wood

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 Answer

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy