Question

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?

Was it helpful?

Solution

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

top -c

OTHER TIPS

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

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

ps aux

or

ps -fu USERNAME

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

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.

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top