Get the App
SLTechnology News&Howtos  ›  Servers  › 

What is the use of the nohug command in Linux

Shulou Source: shulou.com Published: 2022-06-01 06:34:51 10月02日 Update

This article mainly introduces the use of the nohug command in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

The Linux background run commands cron and crontab, at and & are all run when the account is logged in. If you are not an administrator, you may want to exit the account, but this Linux background run command is very useful if the process is not finished running at the time of exit.

Nohug

If you are running a process and you don't think it will end when you log out of your account, use the nohup command. This command can continue to run the corresponding process after you log out of your account. Nohup means not to hang (no hang up).

The general form of the command is:

Code:

Nohup command &

Use the Linux background run command nohup to submit a job

If you submit a job using the nohup command, by default all output from the job is redirected to a file named nohup.out, unless another output file is specified:

Code:

Nohup command > myout.file 2 > & 1

In the above example, the output is redirected to m y o u t. In f i l e file.

Let's look at an example to verify that the corresponding job can continue to run after exiting the account. Let's first submit a log cleanup process called p s 1:

Code:

$nobup ps1 &

Now exit the s h e l l, log in again, and execute the following command:

Code:

$ps x | grep ps1

We see that the script is still running. If the system does not support the ps x command, use the ps-ef | grep ps1 command.

Thank you for reading this article carefully. I hope the article "what is the use of nohug commands in Linux" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Command run process code article job background account file output example account face-to-face support login value interest and at the same time form Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Linux Redmi OPPO Reno macOS