基本上我想让所有进程已经睡了一个多小时。
我知道ps中存在etime,但遗憾的是它显示了整个生命周期。
如何在linux下完成(最好用ps)?
答案 0 :(得分:4)
/proc/pid/sched
文件包含一公吨调度数据:
$ cat sched
bash (2192, #threads: 1)
---------------------------------------------------------
se.exec_start : 294360163.632873
se.vruntime : 17694.720927
se.sum_exec_runtime : 2643.766318
se.statistics.wait_start : 0.000000
se.statistics.sleep_start : 294360163.632873
se.statistics.block_start : 0.000000
se.statistics.sleep_max : 34689385.720961
se.statistics.block_max : 11337.665116
se.statistics.exec_max : 7.657145
se.statistics.slice_max : 0.550257
se.statistics.wait_max : 7.464190
se.statistics.wait_sum : 37.981183
se.statistics.wait_count : 13774
se.statistics.iowait_sum : 1556.105204
se.statistics.iowait_count : 278
sched_info.bkl_count : 0
se.nr_migrations : 2816
se.statistics.nr_migrations_cold : 0
se.statistics.nr_failed_migrations_affine: 0
se.statistics.nr_failed_migrations_running: 335
se.statistics.nr_failed_migrations_hot: 14
se.statistics.nr_forced_migrations : 0
se.statistics.nr_wakeups : 13471
se.statistics.nr_wakeups_sync : 3293
se.statistics.nr_wakeups_migrate : 2532
se.statistics.nr_wakeups_local : 655
se.statistics.nr_wakeups_remote : 12816
se.statistics.nr_wakeups_affine : 78
se.statistics.nr_wakeups_affine_attempts: 9452
se.statistics.nr_wakeups_passive : 0
se.statistics.nr_wakeups_idle : 0
avg_atom : 0.196329
avg_per_cpu : 0.938837
nr_switches : 13466
nr_voluntary_switches : 13447
nr_involuntary_switches : 19
se.load.weight : 1024
policy : 0
prio : 120
clock-delta : 95
我建议您阅读/proc/*/sched
个文件,查找一小时内没有变化的se.statistics.nr_wakeups
或se.statistics.wait_count
行。我不知道哪一个会给你'更好'的结果,但是尝试两个:)并看看哪个给你答案就像你期望的那样。