Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我搜索了 coreutils 超时和其他超时脚本,他们申请了 CDM ,但我想为 linux 脚本申请超时,如果一段时间没有完成的话。喜欢:
cd XXX && CMD && sleep 3 && kill -0 XX
怎么做?
您可以将子shell 的生成传递给超时,并让子shell 运行需要超时的代码:
#!/bin/bash timeout 5 bash -c "ping google.com -c 2; ping yahoo.com -c 10"
如果你明确你需要什么,可能会有更清洁的方法来实现这一点。