Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
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.
Zo schrijf je het
pgrep [OPTION]... PATTERN
pkill [OPTION]... [-SIGNAL] PATTERN
pidwait [OPTION]... PATTERNOpties 32
Meest gebruikt
Signal (pkill)
Output (pgrep)
Select
Niets past bij dit filter.
Voorbeelden 11
$ als gewone gebruiker# als root (of met 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.
Niets past bij dit filter.
Let op
Exitcodes
0 :: At least one process matched. 1 :: No process matched. 2 :: Syntax error. 3 :: Fatal error.