AIX 中 shell 脚本的时间限制

AWS*_*ner 2 linux aix

我想运行一个时限为 50 秒的 shell 脚本。下面在 linux 中工作正常。

  timeout 50s sudo sh my-script.sh
Run Code Online (Sandbox Code Playgroud)

但是我有 AIX 服务器,我想在 50 秒的时间限制内运行上面的脚本。所以我在 AIX 中运行相同的命令,但它给了我

     timeout command not found
Run Code Online (Sandbox Code Playgroud)

AIX 中是否有类似的超时命令?

Joh*_*ald 5

可能您正在使用 GNU coreutils 的超时。您可以从 AIX Toolbox for Linux 或第三方源安装它,或者自己编译它。

或者,Perl 可以安排一个 SIGALRM。几个 CPAN 模块都有超时和一般信号处理的例子。Perl 应该更便携一点,如果这不是让您烦恼的唯一平台差异,它可能会很有用。