【发布时间】:2015-04-29 07:25:14
【问题描述】:
我有两个单衬:
首先。我预计 5 秒后会杀死 sh -c "..." 命令,但它会一直存在到超时退出(10 秒)
timeout -k 5s 10s sh -c 'sleep 20s && echo "Long running command which is visible under: ps -elf | grep sleep during whole life (10s) time of timeout command"'
第二。我预计超时将退出并返回代码 124(因为 sh -c "..." 命令仍在运行)而命令 sh -c "..." 将继续运行(因为未设置超时的终止选项)
timeout 10s sh -c 'sleep 20s && echo "Long running command which is visible under: ps -elf | grep sleep during whole life (10s) time of timeout command"'
似乎传递给 timeout 的参数运行的时间与 timeout 命令本身一样(它不会提前终止,也不会在超时后存活)那么 kill 选项的目的是什么?
【问题讨论】: