ssh中断while

 

管理远程服务器时 不可避免的使用while ,但是当在while下执行循环时 ssh会中断 ,用for执行就不会出现这种问题

 

 

解决办法有两个

 

 

1.用for循环替代 while循环 

 

2. 用while循环时 ,ssh 增加 -n参数 

 

 

 

 man ssh

 

     -n      Redirects stdin from /dev/null (actually, prevents reading from stdin).  This must be used when ssh is

             run in the background.  A common trick is to use this to run X11 programs on a remote machine.  For exam-

             ple, ssh -n shadows.cs.hut.fi emacs & will start an emacs on shadows.cs.hut.fi, and the X11 connection

             will be automatically forwarded over an encrypted channel.  The ssh program will be put in the back-

             ground.  (This does not work if ssh needs to ask for a password or passphrase; see also the -f option.)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值