Gnu并行卡住了,没有输出

Posted

技术标签:

【中文标题】Gnu并行卡住了,没有输出【英文标题】:Gnu parallel getting stuck, not giving output 【发布时间】:2020-01-17 07:42:41 【问题描述】:

Parallel 似乎已正确安装,因为我能够运行基本的并行检查命令。

# parallel --version
GNU parallel 20161222
Copyright (C) 2007,2008,2009,2010,2011,2012,2013,2014,2015,2016
Ole Tange and Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
GNU parallel comes with no warranty.

Web site: http://www.gnu.org/software/parallel

When using programs that use GNU Parallel to process data for publication
please cite as described in 'parallel --citation'.

但是当我尝试在远程服务器上执行查询时,它没有给出任何输出,也没有返回提示。例如:-

parallel ssh  hostname :::: hosts
Academic tradition requires you to cite works you base your article on.
When using programs that use GNU Parallel to process data for publication
please cite:

  O. Tange (2011): GNU Parallel - The Command-Line Power Tool,
  ;login: The USENIX Magazine, February 2011:42-47.

This helps funding further development; AND IT WON'T COST YOU A CENT.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing.

To silence this citation notice: run 'parallel --citation'.

在上面的例子中,hosts 文件包含一个远程服务器 IP 的列表

即使是一个简单的 parallel echo ::: A B C 命令也会给出输出..

我尝试使用 /usr/bin/parallel 运行,但问题仍然存在..

当我使用 bash -x 运行命令时,出现以下错误:-

bash -x parallel ssh  hostname :::: hosts
+ use IPC::Open3
/usr/bin/parallel: line 22: use: command not found
/usr/bin/parallel: parallel: line 24: syntax error near unexpected token `('
/usr/bin/parallel: parallel: line 24: `use POSIX qw(:sys_wait_h setsid ceil :errno_h);'

我检查了文件 /usr/bin/parallel 对我来说似乎没问题。

无法找到解决方案。非常感谢任何帮助。 谢谢。

UPDATE_1:-

root@sg-server:[~]:# parallel -Dall echo ::: 1
shell? perl /usr/bin/parallel -Dall echo ::: 1
shell? -bash
which -bash => shell path /bin/bash
Academic tradition requires you to cite works you base your article on.
When using programs that use GNU Parallel to process data for publication
please cite:

  O. Tange (2011): GNU Parallel - The Command-Line Power Tool,
  ;login: The USENIX Magazine, February 2011:42-47.

This helps funding further development; AND IT WON'T COST YOU A CENT.
If you pay 10000 EUR you should feel free to use GNU Parallel without citing.

To silence this citation notice: run 'parallel --citation'.

Open file descriptors: 2 1
echo Context:  Non: 4 Ctxgrp:  NonCtxGrp: 1
echo ▒<▒> Context:  Non: 4 Ctxgrp: 1 NonCtxGrp: 1
Wanted procs: 16
MultifileQueue->empty  RecordQueue->empty CommandLineQueue->empty JobQueue->empty  MultifileQueue->empty  RecordQueue->empty eval  1
noncontext + command: 5
context+noncontext + command: 5
cmd_line->number_of_args 1
Replace echo ▒<▒>
Target: echoTarget: ▒<▒>Replacing in ▒<▒>
Return echo 1
noncontext + command: 5
context+noncontext + command: 5
noncontext + command: 5
context+noncontext + command: 5
6 == 6 echo 1
Time to fork 1 procs: 0  (processes so far: 1)
MultifileQueue->empty 1 RecordQueue->empty 1CommandLineQueue->empty 1JobQueue->empty 1 RecordQueue-unget ''
JobQueue->empty  Limited to procs: 1
JobQueue->empty  Running jobs before on ::
: has  out of 1 jobs running. Start another.
JobQueue->empty  Command to run on ':': 'echo 1'
 processes . Starting (1): echo 1
bash -c testfun\(\)\ \\ rm\ /tmp/parTMasE.tst\;\ \\;\ export\ -f\ testfun\;\ perl\ -MIPC::Open3\ -e\ if\\\(\\\$pid\\\=::open3\\\(\\\$i,\\\$o,\\\$e,\\\"-\\\"\\\)\\\)\\\ \\\\\\ wait\\\;\\\ \\\\\\ else\\\ \\\\\\ exec\\\(\\\"bash\\\",\\\"-c\\\",\\\"testfun\\\ \\\&\\\&\\\ true\\\"\\\)\\\;\\\ \\\ 2>/dev/null


^Ckill_sleep TERM
kill_sleep TERM
kill_sleep TERM
kill_sleep KILL

即使在运行parallel -Dall echo ::: 1 命令时,我也必须按 CTRL+c 才能返回提示。

【问题讨论】:

您所做的一切都是正确的(bash -x 除外:不支持)。我唯一能想到的是/etc/parallel/config 是否包含您的包管理器安装的内容。尝试删除它。 如果这不起作用,请尝试发布以下输出:parallel -Dall echo ::: 1。它应该可以帮助我们找出问题所在。 感谢@OleTange 先生抽出宝贵时间。我用parallel -Dall echo ::: 1 的输出更新了我的帖子。 如果挂了,发布strace -ff [same command as above]的输出 strings /usr/local/bin/rm 的输出是什么?我认为该命令不是普通的rm,而是它询问Your name: 并等待输入。这将解释为什么 GNU Parallel 会感到困惑。 【参考方案1】:

正如我们在 cmets 中调试的那样,您的 (/usr/local)/bin/rm 不是正常的 (/usr/local)/bin/rm

【讨论】:

以上是关于Gnu并行卡住了,没有输出的主要内容,如果未能解决你的问题,请参考以下文章

Spring Batch多线程卡住没有任何异常输出

GNU Linker - 孤立的部分和符号赋值

是否可以通过 GNU 并行将 awk 写入多个文件?

gnu并行管道sed - 没有输入文件错误

使用 GNU nm 实用程序时跳过地址输出

通过将命令行工具包装在带有 gnu 信号量的 bash 脚本中来并行化命令行工具