Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux ssh上命令的不同输出_Linux_Ssh - Fatal编程技术网

Linux ssh上命令的不同输出

Linux ssh上命令的不同输出,linux,ssh,Linux,Ssh,我想使用top通过ssh转储特定进程的cpu使用情况,并希望显示完整的命令行。 当我使用ssh连接到服务器并在本地执行命令时,我看到以下内容: remote-server$ top -c -b -n 1 |grep redis-server 5137 redis-user 20 0 83.5g 23g 884 S 13.7 29.3 13388:28 ./bin/redis-server *:11000 local-desktop$ ssh news-cache1 "top

我想使用top通过ssh转储特定进程的cpu使用情况,并希望显示完整的命令行。 当我使用ssh连接到服务器并在本地执行命令时,我看到以下内容:

remote-server$ top -c -b -n 1 |grep redis-server
 5137 redis-user   20   0 83.5g  23g  884 S 13.7 29.3  13388:28 ./bin/redis-server *:11000 
local-desktop$ ssh news-cache1 "top -c -b -n 1 |grep redis-server"
 5137 redis-user   20   0 83.5g  23g  884 S 13.7 29.4  13388:55 ./bin/redis-server 
但是,当我通过ssh执行相同的命令时,我看到以下内容:

remote-server$ top -c -b -n 1 |grep redis-server
 5137 redis-user   20   0 83.5g  23g  884 S 13.7 29.3  13388:28 ./bin/redis-server *:11000 
local-desktop$ ssh news-cache1 "top -c -b -n 1 |grep redis-server"
 5137 redis-user   20   0 83.5g  23g  884 S 13.7 29.4  13388:55 ./bin/redis-server 
我不明白为什么在ssh上运行命令时没有获得完整的命令行(带有主机和端口参数*:11000)

谁能告诉我我做错了什么


我的本地桌面是OS X,El Capitan,而远程服务器是centos 6。

在ssh中使用-t选项重新运行该命令

local-desktop$ ssh -t news-cache1 "top -c -b -n 1 |grep redis-server"

当您远程运行命令时,ssh客户端会分配一个宽度有限的tty终端。指定的终端宽度不足以显示您感兴趣的完整行。添加-t将强制执行伪终端分配。从


在ssh中使用-t选项重新运行该命令

local-desktop$ ssh -t news-cache1 "top -c -b -n 1 |grep redis-server"

当您远程运行命令时,ssh客户端会分配一个宽度有限的tty终端。指定的终端宽度不足以显示您感兴趣的完整行。添加-t将强制执行伪终端分配。从


“当您远程运行命令时,ssh客户端会分配一个宽度有限的tty终端”实际上,当您运行远程命令时,默认情况下它根本不会分配tty。谢谢kdeb。ssh开始工作后,我用pssh尝试了相同的命令,但即使在分配了终端(-X-tt)之后也失败了。在pssh的情况下,伪终端宽度似乎不够,最终能够通过如下设置终端宽度使其工作:
pssh-i-X-tt-H news-cache1“stty columns 200;top-c-b-n 1 | grep redis server”
“ssh客户端在远程运行命令时分配宽度有限的tty终端”实际上,当您运行远程命令时,默认情况下它根本不分配tty。谢谢kdeb。ssh开始工作后,我用pssh尝试了相同的命令,但即使在分配了终端(-X-tt)之后也失败了。在pssh的情况下,伪终端宽度似乎不够,最终能够通过如下设置终端宽度使其工作:
pssh-i-X-tt-H news-cache1“stty columns 200;top-c-b-n1 | grep redis server”