加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – 防止xargs在出错时退出

发布时间:2020-12-15 18:43:22 所属栏目:安全 来源:网络整理
导读:根据手册页,如果其中一条执行行以255错误退出,则xargs将退出: If any invocation of the command exits with a status of 255,xargs will stop immediately without reading any further input. An error message is issued on stderr when this happens.
根据手册页,如果其中一条执行行以255错误退出,则xargs将退出:

If any invocation of the command exits with a status of 255,xargs will stop immediately without reading any further input. An error message is issued on stderr when this happens.

我怎样才能让xargs不这样做?

我有一个1500左右的批处理作业,我想要运行,一次50行.我发现它总是在某条线上死亡,而没有完成这项工作.不好!

一个更好的问题,描述我想要做的问题是:

如何运行1500行批处理脚本,一次50行,这样它就不会退出中间的作业,从而将输出捕获到某种日志文件中?

您可以使用另一个简单的bash脚本包装perl脚本:
#!/bin/bash
real-command "$@" || exit 0

这将调用real-command传递它传递给这个伪命令的所有参数,并且它将始终返回0退出代码(这意味着它总是成功),并且xargs将永远不会停止.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读