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?
7 Answers
Simply use the --full-commands
option to show the full command line for each process :
top -c

- 20,883
- 16
- 73
- 86
-
is that GNU-top only? doesn't appear to work on OSX (assuming it uses BSD top?) – nmr Mar 31 '14 at 18:32
Press "c
" and display the command-line - that will allow you to see what they are.

- 52,368
- 9
- 94
- 137
You might also check out the ps command. Depending on your system:
ps aux
or
ps -fu USERNAME

- 7,686
- 4
- 29
- 36
Do you search for a way to display the full command line? Then simply press 'c
'

- 52,533
- 16
- 102
- 136
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.

- 122,029
- 33
- 303
- 309
-
Also make sure you don't use "#!/usr/bin/env python" at the start of the script. Just use "#!/usr/bin/python". – pixelbeat Mar 03 '09 at 23:36
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.

- 292
- 1
- 5
- 12
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.

- 11,397
- 8
- 56
- 61