Runtime.getRuntime().exec("top -n 1>text.txt");或 test.sh:!/bin/bash top -n 1>test.txt Runtime.getRuntime().exec("test.sh");Runtime.getRuntime().exec("bash test.sh");多试试,肯定是这样调用的,只有这个方法是调用本地进程的。
java如何调用Linux下的top命令
Runtime.getRuntime().exec("top -n 1>text.txt");
或
test.sh:
#!/bin/bash
top -n 1>test.txt
Runtime.getRuntime().exec("test.sh");
Runtime.getRuntime().exec("bash test.sh");
多试试,肯定是这样调用的,只有这个方法是调用本地进程的。2007-12-18