Your sample
Code:
ps -fu albert | grep server.py
filters for user albert, so only if you run this as user albert you need a | grep -vw grep
Yes, pgrep is better.
pgrep by default takes the short ps name, in the case of "python server.py" it might be just "python" that is of course too unprecise.
pgrep -f
takes the full ps name.
pgrep -u albert
filters for user albert
Code:
pgrep -fu albert "server.py"
works like your sample but prints the pid(s), and can safely be run as user albert.
Consult the man page for further options
History:
pgrep and pkill were developed by Sun Microsystems for their Solaris, and re-engineered in Linux and some Unixes.
It takes many options that are known from ps and grep, so it is easy to use.
Another Linux command is pidof. pidof comes with some magic that might detect script names as well. But magic is hard to guess - I often need extensive test so generally prefer pgrep.