killall也可以跟进程名
killall – kill processes by name
killall sends a signal to all processes running any of the specified commands. If no signal name is specified, SIGTERM is sent.
kill 是要据进程号来杀死进程,加-9强制杀死
结合ps 或 pgrep
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.
但是这样只会显示进程号,怎么办? 永远不要忘了man一下
man pgrep里给出了实例
我试了一下,如
ps `pgrep -u www-data` 或者 ps $(pgrep -u www-data) 可以查看到详细的属于www-data用户的进程
root@debian:~# ps `pgrep -u www-data`
PID TTY STAT TIME COMMAND
3128 ? S 0:00 : worker process
12245 ? S 0:04 php-fpm: pool www
12246 ? S 0:04 php-fpm: pool www
12247 ? S 0:05 php-fpm: pool www
12248 ? S 0:06 php-fpm: pool www
12249 ? S 0:05 php-fpm: pool www
12250 ? S 0:05 php-fpm: pool www
Leave a Reply