Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of the nohug command in Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report