【问题标题】:Linux: Stop monitoring tools when a process has terminatedLinux:进程终止时停止监视工具
【发布时间】:2016-10-23 13:33:38
【问题描述】:

我必须在 Linux 上启动一些基准测试并通过一些监控工具来监控它们,包括 vmstat 和 iostat。 基准测试将执行几个小时,所以我想自动化监控过程,每X秒执行一次(例如)vmstat,直到基准测试完成它的工作,这样它就不会无限期地继续下去,直到不是我杀死它手动。 我该怎么做?

【问题讨论】:

    标签: linux bash performance monitoring benchmarking


    【解决方案1】:

    在后台运行 vmstat 5 使其每 5 秒打印一次。

    记录它的 PID 并在基准测试完成后将其杀死。

    vmstat 5 > vmstat.log &
    pid_of_vmstat=$!
    
    run_benchmark
    
    kill "$pid_of_vmstat"
    

    未经测试,如果其中任何一个不起作用,请阅读 bash 手册页。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-12
      • 1970-01-01
      • 2015-10-18
      • 2011-11-14
      • 1970-01-01
      • 2018-08-10
      • 2015-01-27
      • 1970-01-01
      相关资源
      最近更新 更多