执行一个进程30秒并得到输出
我需要运行一个进程 30 秒,在它运行时我必须将输出存储在文本文件中。 30 秒后我必须销毁该进程。我知道如何运行该进程以及如何将数据存储在文件中,但不知道如何仅执行 30 秒(如果不停止该进程将花费更长的时间)。
谢谢。
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 if not stopped).
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样:
(仍需要确保 %1 始终引用该作业,我正在检查如何)PS 我假设您正在谈论 shell 命令执行?我给出的答案在 bash
编辑中有效:将 %1 更改为 %+
How about:
(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 %+