I spend a lot of time restarting daemonized ruby processes and need to locate their PIDs on the fly. I got really, really tired of typing all the grep nonsense over and over.
Here is a quick bash script to locate processes by command text.
— begin code –
#!/bin/bash
ps ax | grep "$1" | grep -v grep | grep -v "fp $1"
— end code —
example:
[admin@mon2 scripts]# fp ruby
1160 ? S 09:30 0:15 ruby /scripts/srv.rb
1161 ? S 09:30 0:16 ruby /scripts/test.rb
2583 ? S Jun09 0:06 ruby /scripts/poll.rb
3068 ? S Jun09 71:01 ruby /scripts/diff.rb



the
grep -v grepprobably works best here, but another neat trick that you can pull, which is nice for ad hoc process grepping is this:ps auxww | grep [s]omething
that will specifically exclude the grep process from the list of matches.
nice trickery!