0

I want to develop a task manager in Ubuntu Linux. I have a task manager in windows that I am running in Eclipse. I am getting the output. But in Linux, what is the equivalent method for "tasklist.exe" to find the processes running?

Please help me..

Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
celebrate celeb
  • 75
  • 1
  • 3
  • 10

2 Answers2

1

you can use the ps command to determine the user, process, usage and other trivia.

Don't you consider top as an equivalent of tasklist.exe?

Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
prathmesh.kallurkar
  • 5,468
  • 8
  • 39
  • 50
  • :yes i understand top is an option. But I want to have the equivalent of Runtime.getRuntime().exec("tasklist.exe") in linux to get the running processes in linux. pls help – celebrate celeb Apr 18 '12 at 08:10
1

ps -ef will get you all of the tasks running

man ps will get you all of the options

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class psef
{

public static void main(String args[]) throws Exception
{

    try
    {
        String line;
        Process p = Runtime.getRuntime().exec("ps -ef");
        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
        while ((line = input.readLine()) != null)
        {
            System.out.println(line);
        }
        input.close();
    }
    catch (Exception err)
    {
        err.printStackTrace();
    }
}
}
Stuart Siegler
  • 1,686
  • 4
  • 30
  • 38
  • ps, man, top will not work in java. I want to know the method i have to put in java program for my task manager in linux. Pls help – celebrate celeb Apr 19 '12 at 04:55
  • Updated, with the new requirements – Stuart Siegler Apr 19 '12 at 13:22
  • @Nathan Fellman I just udpated/posted the code -- he didnt say what he was really trying to do until his comment. I suspect that in his code, he didnt grab the output with an InputStreamReader... – Stuart Siegler Apr 19 '12 at 13:34
  • i have done the part till getting the contents for a task manager in the console and writing it into a file. Now from the file, i need to selct only the contents to be displayed in a msgbox say for ex., PID,CM,CPU%,MEM%. Is there a command in linux to choose except the 'CUT' cmd? Pls help me in going about this – celebrate celeb Apr 26 '12 at 08:49
  • post this as a new question, with the output you have and output you need – Stuart Siegler Apr 26 '12 at 11:56
  • Hi, I have done the initial part and the msgbox displays all that I need to display (Image name,PID,Session name,Session#,Memory usage). I have separately developed a window with 5 tabs using java swings. Now i want to put each of these displayed results into tabs. How do I go about doing this? Kindly help me since I am a beginner. Thanks... – celebrate celeb May 04 '12 at 05:10
  • Open this as new/separate question – Stuart Siegler May 04 '12 at 13:14