by voidz · 10y ago · 0 comments
edit: `ps aux|grep`, indeed. Silly me in the early hours of a rest day :).
pgk ()
{
[ -z "$*" ] && echo 'Usage: pgk <pattern>' && return 1;
pgrep -fl $*;
[ "$?" == "1" ] && echo 'No processes match' && return 1;
echo 'Hit [Enter] to pkill, [Ctrl+C] to abort';
read && pkill -f $*
}What's wrong with doing that?
I've been doing that for so long I don't know why I do it
ps -C procname
ps -p pid
ps -u username
ps -t ttyname
ps -f [-w [-w]]
ps -o output-formatAnyway, it's just a reflex now to always:
ps aux | grep <program> | grep -v grep ps -ef | grep [p][r][o][g][r][a][m]Yes, I do sometimes have processes with camel-cased names which I may or may not remember exactly. So you:
ps auwx | grep -i {lc-version-of-camel-cased-name}In regard to ps you can memorize a few commands until something truly weird comes up since you will probably use other more specialized snapshotting and tracing tools for anything somewhat difficult to troubleshoot.
Yup, this is true. And I did. But sometimes you just need less dense manual pages.
- grep bash /proc/*/status
- readlink /proc/*/fd/* | grep /runThat's why I was so happy to stumble across pstree the other day. Even the man page is excellent! Every now and again, I'll come across a util like this that I can put into immediate action w/o lots of deciphering. pstree -a is awesome for a relative newbie like me.