
One way is to remove the job from the shell’s job control using the disown shell builtin: disown There are several ways to keep the process running after the interactive shell session ends. If your connection drops or you log out of the shell session, the background processes are terminated. Keep Background Processes Running After a Shell Exits # Move the stopped process to the background by typing bg.To move a running foreground process in the background: To terminate the background process, use the killĬommand followed by the process ID: kill -9 25177 Move a Foreground Process to Background # If you have multiple background jobs, include % and the job ID after the command: fg %1 To bring a background process to the foreground, use the fg command: fg The output includes the job number, process ID, job state, and the command that started the job: + 25177 Running ping & Use the jobs utility to display the status of all stopped and background jobs in the current shell session: jobs -l

>/dev/null 2>&1 means redirect stdout to /dev/null and stderr to stdout To run a command in the background, add the ampersand symbol ( &) at the end of the command:
#Close session on ping console how to
We will show you how to start a command in the background and how to keep the process running after the shell session is closed. In this article, we will talk about the background processes is Linux. Another option is to run the command in the background.Ī background process is a process/command that is started from a terminal and runs in the background, without interaction from the user.

The most obvious and straightforward option is to start a new shell session and run the command in it. What if the command takes a long time to finish, and you want to run other commands in the meantime? You have several options at your disposal. When a process runs in the foreground, it occupies your shell, and you can interact with it using the input devices. This is called running the command in the foreground or foreground process. Typically when you run a command in the terminal, you have to wait until the command finishes before you can enter another one.
