A process command in top
Asked Answered
S

7

28

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?

Skier answered 26/2, 2009 at 15:14 Comment(0)
R
58

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

top -c
Radborne answered 26/2, 2009 at 15:20 Comment(1)
is that GNU-top only? doesn't appear to work on OSX (assuming it uses BSD top?)Blister
L
14

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

Lubbock answered 26/2, 2009 at 15:18 Comment(0)
H
4

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

ps aux

or

ps -fu USERNAME
Hubbs answered 26/2, 2009 at 15:20 Comment(1)
It's like you're asking ps to say "Frak you USERNAME!" :-PAnchoveta
M
3

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

Metabolic answered 26/2, 2009 at 15:19 Comment(0)
R
3

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.

Restrain answered 26/2, 2009 at 15:21 Comment(1)
Also make sure you don't use "#!/usr/bin/env python" at the start of the script. Just use "#!/usr/bin/python".Cheryllches
T
1

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.

Throe answered 26/2, 2009 at 15:34 Comment(0)
R
1

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.

Responsum answered 26/2, 2009 at 22:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.