Cheery
Cheery

Reputation: 25463

A process command in top

The problem comes up when you run couple of python scripts. in top at command, it shows only 'python' with these scripts. How to rename a process or otherwise tag it so that I could tell them apart in top?

Upvotes: 28

Views: 21420

Answers (7)

slacy
slacy

Reputation: 11783

I'm not sure if you can do this in Python, but in C programs, argv[0] can actually be modified to show a "prettier" name for the process. I think the constraint is that the new name has to be equal or shorter in length than the original name, such that you don't stomp on memory.

Upvotes: 1

aks
aks

Reputation: 292

You can also try ps aux or ps -au USESRNAME. ps is quite nice since you can format the output, eg. ps -u USERNAME -o pid,command which would display pid and command of the process. Then you can also filter it through grep (ps -u USERNAME -o pid,command|grep python) to see all the running python scripts.

Upvotes: 1

chaos
chaos

Reputation: 124365

This is probably going to be platform and version dependent, but on the platforms I use (CentOS, Debian), top normally displays the last part of the command run as the ID.

I'm guessing, therefore, that you're running your scripts by doing "python scriptname".

If you change your scripts to being executable as themselves (chmod +x and first line #!/usr/bin/python [or wherever python lives]), and then run them using just "scriptname" rather than "python scriptname", they should show up in top as their filename.

Upvotes: 3

Wookai
Wookai

Reputation: 21793

Simply use the --full-commands option to show the full command line for each process :

top -c

Upvotes: 58

Jeremy L
Jeremy L

Reputation: 7797

You might also check out the ps command. Depending on your system:

ps aux

or

ps -fu USERNAME

Upvotes: 4

Johannes Weiss
Johannes Weiss

Reputation: 54111

Do you search for a way to display the full command line? Then simply press 'c'

Upvotes: 3

Douglas Leeder
Douglas Leeder

Reputation: 53285

Press "c" and display the command-line - that will allow you to see what they are.

Upvotes: 14

Related Questions