linux üzerinde
(Ubuntu 14 çalıştırıyorum)
public class SO {
public static void main(String[] args) throws Exception {
System.out.println(getStartTime(29489));
}
private static String getStartTime(int pid) throws IOException {
String start = null;
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("ps -ewo pid,lstart");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.startsWith(pid+" ")) {
int firstSpace = line.indexOf(" ");
start = line.substring(firstSpace+1);
break;
}
}
return start;
}
}
Çıktı
Çar Nis 13 21:13:10 2016
komut satırı doğrulama
[email protected]:~$ ps -ewo pid,lstart | grep 29489
29489 Wed Apr 13 21:13:10 2016
Kopyala - http://stackoverflow.com/questions/54686/how-to-get-a-list-of-current-op benim için önemli olan en-windows-process-with-java – deeveeABC
benim için önemli, bu listeden de alabilir miyim? – Gobliins
Linux için, PID'nin yanında listelenen başlangıç zamanını almak için "ps -eo pid, stime" kullanın. Bu komutu java'dan http://stackoverflow.com/questions/54686/how-to-get-a-list-of-current-open-windows-process-with-java – mdewit