开发者

Execute one process for 30 seconds and get the output

I need to run a process for 30 seconds and while it is running I have to store the output in a text file. After 30 seconds I'd have to destroy the process. I know how to run the process and how to store data in a file but don't know how to do it for 30 seconds only (the process would take much longer 开发者_Go百科if not stopped).

Thanks.


How about:

my_long_command & sleep 30 && kill %+

(Still need to make sure %1 will always reference that job, I'm checking how)

P.S I'm assuming you're talking about shell command execution? The answer I gave works in bash

EDIT: Changed %1 to %+

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜