views:

417

answers:

7

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?

+1  A: 

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

Douglas Leeder
A: 

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

Johannes Weiß
A: 

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

ps aux

or

ps -fu USERNAME
Nerdling
It's like you're asking ps to say "Frak you USERNAME!" :-P
Jweede
+3  A: 

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

top -c
Wookai
+2  A: 

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.

chaos
Also make sure you don't use "#!/usr/bin/env python" at the start of the script. Just use "#!/usr/bin/python".
pixelbeat
A: 

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.

aks
+1  A: 

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.

slacy
wow. Need to try this out. Sounds like a hack though.
Cheery