System Administration Scripting

2007年4月7日星期六

Bash : pgrep

pgrep: 等价于 ps -ef | egrep

# ps -ef | egrep '^root ' | awk '{print $2}' | awk '{printf("%s,",$1)}'
1,2,3,4,5,20,21,38,39...
可以使用pgrep,显示所有root帐号下的进程,并用逗号隔开:
# pgrep -d, -u root
1,2,3,4,5,20,21,38,39...
pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout.All the criteria have to match.For example,
pgrep -u root sshd
will only list the processes called sshd AND owned by root. On the other hand,
pgrep -u root,daemon
will list the processes owned by root OR daemon.

pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout.

Bookmark this post:
Ma.gnolia DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google


0 评论:

相关文章

©2007