Methods of payment Abuse

Working in a Linux background process

27.01.2023, 23:58
We told you what a process is in the Linux background and how to run it correctly. In this article we will tell you how to work in this mode.

How is the work in the background

Running a script in Linux is one task, you need to take care of it so that it functions properly immediately after closing the terminal. The terminal closes like this: 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 techniques for how to save them in case the connection with the interactive shell is lost
 
First: remove the task queue from the task using disown:
disown
As in the previous cases, if there are several processes running at the same time, you should specify the number of the one about which the action will be performed:
disown %1
Make sure that the task is not in the task list. How to do it? Use the jobs -l utility. To view the entire list of running processes, use the command:
ps aux
The following 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.
 
We have sorted out this issue, as we can see, everything is elementary and simple.