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 pit in the while read loop that calls ssh remote execution code?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

What this article shares to you is about the big pit of calling ssh remote execution code in the while read cycle. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Then began to investigate why it was cut so slowly.

Then start the balabala code log and find that if the test is normal or does not meet the lvs switching standard, the whole code flow can be completed.

Start the balabala code against the log. Then suddenly discover the code structure of the while read loop calling ssh to the remote execution.

The problem here is if you read each node in while read and then check the corresponding health status of that node.

If this node needs to be switched by lvs. Then call ssh to a remote node to execute an operation command.

Execute this ssh because ssh takes stdin as input. So I read all the stdin buffer of while read.

Cause this node to finish processing, while loop, and then start from scratch, read has reached EOF. Then the loop exits.

If this node does not meet the switching criteria, ok, it will not call ssh. Then the latter node is still in the stdin buffer of while read.

Read can read it. Then the whole cycle will run out.

After we take over, it will be very convenient to trace the source of the problem. Of course。 The problem is thus solved.

This is what the big pit of calling ssh remote execution code in the while read loop is like. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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