![什么正在访问我的硬盘?](https://linux22.com/image/1251414/%E4%BB%80%E4%B9%88%E6%AD%A3%E5%9C%A8%E8%AE%BF%E9%97%AE%E6%88%91%E7%9A%84%E7%A1%AC%E7%9B%98%EF%BC%9F.png)
我的硬盘一直在高速运转,但我没有运行任何程序来保证这种持续的活动。我如何才能找出哪些程序在持续访问我的硬盘?
我在 iMac 上,使用 Mac OS X 10.6.4
答案1
DTrace 是你的朋友:
# Files opened by process,
dtrace -n 'syscall::open*:entry { printf("%s %s",execname,copyinstr(arg0)); }'
以下是其他常用命令(也列在DTrace 维基百科文章):
# New processes with arguments,
dtrace -n 'proc:::exec-success { trace(curpsinfo->pr_psargs); }'
# Syscall count by program,
dtrace -n 'syscall:::entry { @num[execname] = count(); }'
# Syscall count by syscall,
dtrace -n 'syscall:::entry { @num[probefunc] = count(); }'
# Syscall count by process,
dtrace -n 'syscall:::entry { @num[pid,execname] = count(); }'
# Disk size by process,
dtrace -n 'io:::start { printf("%d %s %d",pid,execname,args[0]->b_bcount); }'
# Pages paged in by process,
dtrace -n 'vminfo:::pgpgin { @pg[execname] = sum(arg0); }'