Methods of payment Abuse

Working in the Linux background process

27.01.2023, 23:58

We have told you what a Linux background process is and how to start it correctly. In this article we will tell you how it works in this mode.

How a background process works

Running a script in Linux is one task, you need to make sure that it functions properly right after you close the terminal. The terminal is closed in the following way: you need to click on the cross, which is located in the upper corner of the screen, this leads to the termination of all background processes. There are several methods to save them in case the connection with the interactive shell is lost

First: remove the job queue from the task by using disown:

disown

As in the previous cases, if there are multiple processes running concurrently, the number of the one relative to which the action will be performed should be specified:

disown %1

Make sure that the task is not in the task list. How to do this. Use the jobs -l utility. To view the entire list of running processes, the command is used:

ps aux

Next method: you save the running processes with the nohup command. This command after execution will in turn execute another command, all SIGHUP signals will be ignored.

You can run the command in the background like this:

nohup command &

As you can see in the image above, the output of the command will be sent to nohup.out. The most important thing is that after logging out and closing the terminal, the process will continue to function. There are some utilities that allow you to run two or more sessions at once. In particular, Screen and Tmux allow you to do this.

  • Screen or GNU Screen is a terminal multiplexer that allows you to start one work session and open any number of windows (virtual terminals) within it. Processes running in this program will run even if their windows are invisible or the program has stopped running.
  • Tmux is a more modern alternative to GNU Screen. However, the features of Tmux are not fundamentally different - you can open many windows within a single session in the same way. Tasks running in Tmux continue to run if the terminal is closed.

We have solved this issue, as you can see, everything is elementary and simple.