How to find out which python script is using resources?

Can someone tell me how to find out which python script is using lots of system resources?

I can see with the 'top' command that a process called "python" is always near the top of the list.

2603 jesse     20   0  159m  27m  13m S    6  1.4   1:47.74 python

Can someone tell me how to find this specific python script's name?

I could go through the arduous process of disabling startup apps/processes until I finally found the one that starts this python process but there must be a better way of determining what exactly this python process is, yes?

Doing a ps -AH doesn't yield anything useful.

ps -AH

   1 ?        00:00:00 init
...
1325 ?        00:00:00   lightdm
1382 tty7     00:01:57     Xorg
2265 ?        00:00:00     lightdm
2510 ?        00:00:00       gnome-session
2546 ?        00:00:00         ssh-agent
2560 ?        00:00:02         gnome-settings-
2582 ?        00:00:01           syndaemon
2578 ?        00:00:49         compiz
3009 ?        00:00:00           sh
3010 ?        00:00:01             gtk-window-deco
2590 ?        00:00:00         nm-applet
2591 ?        00:00:00         bluetooth-apple
2592 ?        00:00:00         indicator-ubunt
2593 ?        00:00:00         gnome-fallback-
2600 ?        00:00:05         nautilus
2601 ?        00:00:00         everpad
2603 ?        00:02:24         python

I've found the answer myself!

It's

ps -Ao pid,cmd
  • -A = Show All Processes
  • -o pid,cmd = display options: process id, full command string

Adding -H gives you a tree listing so you can see which process started which other process.

ps -AHo pid,cmd

Turns out for me the process in question was /usr/share/screenlets/screenlets-pack-basic/Sysmonitor/SysmonitorScreenlet.py

I think I'll turn off that sysmonitor screenlet since it constantly polls the CPU and uses more memory than than the entire rest of the desktop.