如何vmstat的输出重定向到Android操作系统中的文件? [英] how to redirect the vmstat's output to a file in Android OS?

查看:460
本文介绍了如何vmstat的输出重定向到Android操作系统中的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我连接到我的手机扎根通过亚行的shell命令,我跑
的vmstat 命令,以便观看各种系统资源。是
有没有办法vmstat的输出重定向到一个文件。我想:

I connect to my rooted phone through adb shell command and I run the vmstat command so as to watch various system resources. Is there a way to redirect vmstat's output to a file. I tried:

vmstat > /sdcard/vmstat_output.txt

但它不工作..它创建该文件,但里面有没有数据。

but it doesn't work.. It creates the file but there is no data inside..

任何想法?

推荐答案

好吧,我解决了这一问题。我从<一个下载源代码href=\"http://$c$c.google.com/p/android/issues/attachmentText?id=17996&aid=179960000000&name=vmstat.c&token=795cfaef27ae3d19ba2784afdf94a61f\"相对=nofollow>这里,我增加了一个额外的行:

Ok, I fixed the problem. I download the source from here and I added one extra line:

fflush(stdout);

在print_line命令(行:134)之后。然后,我交叉编译的vmstat.c
海湾合作委员会

agcc vmstat.c -o vmstat

和把文件复制到/ SD卡/通过亚行:

and put the file to the /sdcard/ through the adb:

adb push vmstat /sdcard/

现在重定向作品
完美,因为每个print_line呼叫后,将数据刷新到该文件。正如马克Polhamus提到,
问题是以下事实的vmstat是块缓冲命令,这意味着一个缓冲
已被第一填充有数据,然后这个数据将被刷新到文件..

Now the redirection works perfectly, as after every print_line call, the data are flushed to the file. As Mark Polhamus mentioned, the problem was the fact that vmstat is a block-buffered command, which means that a buffer has to be filled with data first and then this data will be flushed to the file..

非常感谢马克! :)

这篇关于如何vmstat的输出重定向到Android操作系统中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆