Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
pidof NAME prints the PIDs of all processes of that program, on one line. Unlike pgrep, the name must match exactly (no pattern). It is often used inside other commands: kill $(pidof myapp).
Zo schrijf je het
pidof [OPTION]... PROGRAM...Opties 13
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1PIDs of a program
pidof sshd 2215 2210 1010All sshd processes.
2Only one PID
pidof -s chronyd 812For commands that take one PID.
3Use it with kill or renice
kill -HUP $(pidof rsyslogd)Reload by name.
4Find a running script
pidof -x backup.shWithout -x scripts are not found.
5Is it running? (scripts)
pidof -q httpd && echo "httpd runs"Exit code 0 when found.
6Leave out the own shell
pidof -o %PPID -x myscript.shA script that checks if another copy runs.
7Comma separated for other tools
pidof -d, httpd 1420,1421,1422Handy for
top -p.8Watch all processes of a program
top -p $(pidof -d, httpd)Only the web server.
9Threads of a process
ps -L -p $(pidof chronyd)pidof gives the PID, ps the threads.
10Check that a service is not running twice
pidof myapp | wc -wMore than 1 for a single-instance app = a problem.
Niets past bij dit filter.
Exitcodes
0 :: At least one process found. 1 :: Nothing found.