هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
pgrep PATTERN prints the PIDs of processes whose name matches the pattern (a regular expression). pkill PATTERN sends them a signal (TERM by default). Both select with the same options: by user (-u), terminal (-t), parent (-P), full command line (-f) and more.
Run pgrep first with the same options to see what pkill would hit.
طريقة الكتابة
pgrep [OPTION]... PATTERN
pkill [OPTION]... [-SIGNAL] PATTERN
pidwait [OPTION]... PATTERNالخيارات 32
الأكثر استخدامًا
Signal (pkill)
Output (pgrep)
Select
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 11
$ مستخدم عادي# بصلاحية root (أو مع sudo)
1Find PIDs by name
pgrep -l sshd 1010 sshd 2210 sshd-l adds the name.
2See full command lines
pgrep -a python3Find which script is running.
3Stop all processes of a user
pkill -u olduserBefore you delete the account.
4Log out a session
pkill -KILL -t pts/3Ends everything on that terminal.
5Match the full command line
pgrep -af 'backup.sh' pkill -f 'backup.sh'The process name is bash; -f finds the script.
6Count processes
pgrep -c httpd 6Quick health check.
7Wait until a process is gone
pidwait -f backup.sh; echo "backup finished"Then start the next step.
8Reload a daemon by name
pkill -HUP rsyslogdRe-reads the config.
9The newest or oldest match
pgrep -n firefox; pgrep -o httpd-o httpd = the parent of all httpd children.
10Hunt processes that run from /tmp (security)
pgrep -af '/tmp/|/dev/shm/'Suspicious locations for running programs.
11Show what pkill did
pkill -e dd dd killed (pid 4123)Proof of the action.
لا يوجد شيء يطابق هذا الفلتر.
انتبه
رموز الخروج
0 :: At least one process matched. 1 :: No process matched. 2 :: Syntax error. 3 :: Fatal error.