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 realize the disconnection of the terminal but the task is continuous in linux

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

Share

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

This article mainly introduces how to achieve terminal disconnection but continuous tasks in linux, with 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.

It is a common requirement that terminals are disconnected and tasks are constantly needed, but the "nohup command &" approach has been used before.

But sometimes you don't fully estimate the unreliability of some work, and you don't use nohup to do what you think can be done quickly, and it's still a long way off when you're about to get off work. At this time, you can also hang ctrl + z from the foreground, then bg let it run to the background to execute, and finally a disown-a, so you can safely turn off the terminal and go home early. The next time you connect to another terminal, your work will continue, but you can't use a command like fg to get it back to the foreground, and jobs won't show it.

If you want to keep seeing the output of the background process, the previous approach is to redirect it to a file before running it, and then come back to see the file. But if the process has already started, it takes a little bit of effort to redirect it. There are some methods of using gdb on the Internet. I tried not to be very successful. I originally planned to continue to have a look, but found that it was more reliable to use screen honestly.

In fact, the command screen should not be anything new, there are a lot of people in use. But it's still a very new discovery for me. My general routine: create a new screen and name it ftp:

Screen-S ftp

At this point, you will go directly to the new bash, where you will do some time-consuming operations, such as scp and so on. Return from ftp and use the shortcut key ctrl+a d. At this time, you can actually close the current terminal. Open a new terminal and view the list of existing screen:

Screen-ls

See how the upload is going:

Screen-r ftp

Not only is there no interruption in the work of scp, you can also see all the current output of scp, just as the previous terminal did not shut down.

Thank you for reading this article carefully. I hope the article "how to disconnect the terminal in linux but the task is continuous" 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