[英]GNU Parallel runs in script interactively but not in same script via crontab
I'm using GNU Parallel version 20141122 to curl 100 IP addresses in parallel within a larger script. 我正在使用GNU Parallel版本20141122在较大的脚本中并行卷曲100个IP地址。
When I execute the script interactively, Parallel produces the expected results in a log file. 当我交互式执行脚本时,Parallel在日志文件中产生预期的结果。
When I run the same script via a crontab job, no entries are added to the log file although the remainder of the script produces expected results for all of the non-Parallel-related tasks. 当我通过crontab作业运行相同的脚本时,尽管该脚本的其余部分会为所有与并行无关的任务产生预期的结果,但没有将任何条目添加到日志文件中。
The line in the script that executes Parallel is 脚本中执行Parallel的行是
parallel -j30 < contactdevices.input
The file contactdevices.input contains 100 lines like this: 文件contactdevices.input包含100行,如下所示:
./contactdevice.sh 155.156.157.158
contactdevice.sh curls the IP address and appends a one line result to a log file. contactdevice.sh会卷曲IP地址,并将一行结果附加到日志文件中。
My Amazon AMI environment supports more than 40 such simultaneous jobs. 我的Amazon AMI环境支持40多个此类同时作业。
Why does Parallel work within my script when run interactively but appears not to run at all when the identical script is executed via crontab? 为什么交互式运行Parallel可以在我的脚本中运行,但是通过crontab执行相同的脚本时却根本无法运行?
Thanks for your help. 谢谢你的帮助。 I'm pretty much a linux and bash neophyte.
我几乎是linux和bash新手。
Usually the problem with cron
is that you have a limited $PATH. 通常,
cron
的问题是您的$ PATH有限。 Try setting that: 尝试设置以下内容:
PATH=/usr/bin:/bin:/the/dir/containing/contactdevice PATH = / USR / bin中:/ bin中:/该/目录/含有/ contactdevice
and then remove the ./ 然后删除./
The parallel
utility was installed in the the user's bin folder rather than /usr/bin
. parallel
实用程序安装在用户的bin文件夹中,而不是/usr/bin
。 Installing the utility in /usr/bin
solved the problem. 在
/usr/bin
安装实用程序解决了该问题。 Alternatively, we could have solved the problem by specifying the location of parallel
when invoking it. 或者,我们可以通过在调用
parallel
时指定parallel
位置来解决该问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.