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

How to run Linux commands in the background in Linux system

2025-01-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how to run the Linux command in the background in the Linux system, which has a certain reference value. Interested friends can refer to it. I hope you can learn a lot after reading this article.

Put the command in the background to execute the first way to put the command in the background is to add a space & after the command. Commands that are put in the background using this method are executed in the background.

Note that the command that is put into the background cannot interact with the foreground, otherwise the command cannot be executed in the background. For example:

[root@localhost ~] # find /-name install.log & [1] 192 [work number] process # put find commands into the background to execute, and each background command is assigned a work number. Since the command can be executed, a process will be generated, so there will be a process number.

In this way, although the find command is being executed, other operations can still be performed at the current terminal. If the following message appears on the terminal:

[1] + Done find /-name install.log

It proves that the command in the background has been completed. Of course, if the command has the result of execution, it will also be displayed on the operation terminal. Where [1] is the work number of this command, and "+" means that the command is the most recent one to be put in the background.

The command is paused by pressing the Ctrl+Z shortcut key in the background, and the command is paused in the background using this method to put the command into the background, even if it can be executed in the background without interacting with the foreground, because the Ctrl+Z shortcut key is the shortcut key to pause.

[example 1]

[root@localhost ~] # top# during the execution of the top command, pressing the Ctrl+Z shortcut key [1] + Stopped top#top command is placed in the background, the work number is 1, and the status is paused. And, although the top command does not end, you can also get console permissions

[example 2]

[root@localhost ~] # tar-zcf etc.tar.gz/etc# compress / etc/ directory tar: delete the beginning "/" tar from the member name: delete the beginning "/" ^ Z# from the hard link target during execution, press the Ctrl+Z shortcut key [2] + Stopped tar-zcf etc.tar.gz/etc#tar command is placed in the background, the work number is 2, the status is paused

Each command that is placed in the background is assigned a work number. The first command that is put in the background is work number 1; the second command is put in the background, work number is 2, and so on.

Thank you for reading this article carefully. I hope the article "how to run Linux commands in the background in the Linux system" shared by the editor will be helpful to everyone. 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

Development

Wechat

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

12
Report