1PIDOF(8) Linux System Administrator's Manual PIDOF(8)
2
3
4
6 pidof -- find the process ID of a running program.
7
9 pidof [-s] [-c] [-n] [-x] [-m] [-o omitpid[,omitpid..]] [-o omit‐
10 pid[,omitpid..]..] program [program..]
11
13 Pidof finds the process id's (pids) of the named programs. It prints
14 those id's on the standard output. This program is on some systems used
15 in run-level change scripts, especially when the system has a System-V
16 like rc structure. In that case these scripts are located in
17 /etc/rc?.d, where ? is the runlevel. If the system has a start-stop-
18 daemon (8) program that should be used instead.
19
21 -s Single shot - this instructs the program to only return one pid.
22
23 -c Only return process ids that are running with the same root
24 directory. This option is ignored for non-root users, as they
25 will be unable to check the current root directory of processes
26 they do not own.
27
28 -n Avoid stat(2) system function call on all binaries which are
29 located on network based file systems like NFS. Instead of
30 using this option the the variable PIDOF_NETFS may be set and
31 exported.
32
33 -x Scripts too - this causes the program to also return process
34 id's of shells running the named scripts.
35
36 -o omitpid
37 Tells pidof to omit processes with that process id. The special
38 pid %PPID can be used to name the parent process of the pidof
39 program, in other words the calling shell or shell script.
40
41 -m When used with -o, will also omit any processes that have the
42 same argv[0] and argv[1] as any explicitly omitted process ids.
43 This can be used to avoid multiple shell scripts concurrently
44 calling pidof returning each other's pids.
45
47 0 At least one program was found with the requested name.
48
49 1 No program was found with the requested name.
50
52 pidof is actually the same program as killall5; the program behaves
53 according to the name under which it is called.
54
55 When pidof is invoked with a full pathname to the program it should
56 find the pid of, it is reasonably safe. Otherwise it is possible that
57 it returns pids of running programs that happen to have the same name
58 as the program you're after but are actually other programs. Note that
59 that the executable name of running processes is calculated with read‐
60 link(2), so symbolic links to executables will also match.
61
62
64 shutdown(8), init(8), halt(8), reboot(8), killall5(8)
65
67 Miquel van Smoorenburg, miquels@cistron.nl
68
69
70
71 01 Sep 1998 PIDOF(8)