linux - 在ubuntu中检查进程的启动时间后,有没有办法在一定时间后杀死进程?

标签 linux shell ubuntu process

操作系统:Ubuntu

有没有办法使用脚本来检查进程的启动时间,然后在一定时间后终止该进程?

最佳答案

如果您自己启动该过程,请考虑timeout util。

例如,运行 sleep 200d(休眠两百天),但让 timeout 在三秒后停止,并让 time 命令显示消耗的资源:

time timeout 3s sleep 200d

输出:

real    0m3.004s
user    0m0.001s
sys 0m0.003s

关于linux - 在ubuntu中检查进程的启动时间后,有没有办法在一定时间后杀死进程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42965341/

相关文章:

linux - 如何在 Shell 脚本中的变量中捕获 telnet 命令的输出

linux - 如何编写shell脚本来为文件名中具有相同字符串的文件创建zip文件

linux - 如何更改目录颜色?

linux - 如何从文件中提取特定行并将其附加到 shell 脚本中的另一个现有文件,然后从原始文件中删除?

linux - 在 Monodevelop 中获取 F# 教程时遇到问题。成分错误: the type 'Object' is required here and is unavailable

linux - 在登录时运行一次性命令 (Linux)

linux - 每分钟执行一次shell脚本的crontab

bash - 在将 tee 发送到文件之前,如何从 tee 获取 "process"文本

linux - Debian/Ubuntu 软件包默认安装在 root 中

Raspberry Pi 3 上的 Ubuntu Core 16 无法连接到 Docker 守护进程