Advertisement
Guest User

man pgrep

a guest
Apr 17th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. PGREP(1) Linux User's Manual PGREP(1)
  2.  
  3. NAME
  4. pgrep, pkill - look up or signal processes based on name and other attributes
  5.  
  6. SYNOPSIS
  7. pgrep [-cflvx] [-d delimiter] [-n|-o] [-P ppid,...] [-g pgrp,...] [-s sid,...] [-u euid,...] [-U uid,...] [-G gid,...] [-t term,...] [pattern]
  8.  
  9. pkill [-signal] [-fvx] [-n|-o] [-P ppid,...] [-g pgrp,...] [-s sid,...] [-u euid,...] [-U uid,...] [-G gid,...] [-t term,...] [pattern]
  10.  
  11. DESCRIPTION
  12. 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,
  13.  
  14. $ pgrep -u root sshd
  15.  
  16. will only list the processes called sshd AND owned by root. On the other hand,
  17.  
  18. $ pgrep -u root,daemon
  19.  
  20. will list the processes owned by root OR daemon.
  21.  
  22. pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout.
  23.  
  24. OPTIONS
  25. -c Suppress normal output; instead print a count of matching processes.
  26.  
  27. -d delimiter
  28. Sets the string used to delimit each process ID in the output (by default a newline). (pgrep only.)
  29.  
  30. -f The pattern is normally only matched against the process name. When -f is set, the full command line is used.
  31.  
  32. -g pgrp,...
  33. Only match processes in the process group IDs listed. Process group 0 is translated into pgrep's or pkill's own process group.
  34.  
  35. -G gid,...
  36. Only match processes whose real group ID is listed. Either the numerical or symbolical value may be used.
  37.  
  38. -l List the process name as well as the process ID. (pgrep only.)
  39.  
  40. -n Select only the newest (most recently started) of the matching processes.
  41.  
  42. -o Select only the oldest (least recently started) of the matching processes.
  43.  
  44. -P ppid,...
  45. Only match processes whose parent process ID is listed.
  46.  
  47. -s sid,...
  48. Only match processes whose process session ID is listed. Session ID 0 is translated into pgrep's or pkill's own session ID.
  49.  
  50. -t term,...
  51. Only match processes whose controlling terminal is listed. The terminal name should be specified without the "/dev/" prefix.
  52.  
  53. -u euid,...
  54. Only match processes whose effective user ID is listed. Either the numerical or symbolical value may be used.
  55.  
  56. -U uid,...
  57. Only match processes whose real user ID is listed. Either the numerical or symbolical value may be used.
  58.  
  59. -v Negates the matching.
  60.  
  61. -x Only match processes whose name (or command line if -f is specified) exactly match the pattern.
  62.  
  63. -signal
  64. Defines the signal to send to each matched process. Either the numeric or the symbolic signal name can be used. (pkill only.)
  65.  
  66. OPERANDS
  67. pattern
  68. Specifies an Extended Regular Expression for matching against the process names or command lines.
  69.  
  70. EXAMPLES
  71. Example 1: Find the process ID of the named daemon:
  72.  
  73. $ pgrep -u root named
  74.  
  75. Example 2: Make syslog reread its configuration file:
  76.  
  77. $ pkill -HUP syslogd
  78.  
  79. Example 3: Give detailed information on all xterm processes:
  80.  
  81. $ ps -fp $(pgrep -d, -x xterm)
  82.  
  83. Example 4: Make all netscape processes run nicer:
  84.  
  85. $ renice +4 `pgrep netscape`
  86.  
  87. EXIT STATUS
  88. 0 One or more processes matched the criteria.
  89. 1 No processes matched.
  90. 2 Syntax error in the command line.
  91. 3 Fatal error: out of memory etc.
  92.  
  93. NOTES
  94. The process name used for matching is limited to the 15 characters present in the output of /proc/pid/stat. Use the -f option to match against the complete command line, /proc/pid/cmdline.
  95.  
  96. The running pgrep or pkill process will never report itself as a match.
  97.  
  98. BUGS
  99. The options -n and -o and -v can not be combined. Let me know if you need to do this.
  100.  
  101. Defunct processes are reported.
  102.  
  103. SEE ALSO
  104. ps(1), regex(7), signal(7), killall(1), skill(1), kill(1), kill(2)
  105.  
  106. STANDARDS
  107. pkill and pgrep were introduced in Sun's Solaris 7. This implementation is fully compatible.
  108.  
  109. AUTHOR
  110. Kjetil Torgrim Homme <kjetilho@ifi.uio.no>
  111.  
  112. Albert Cahalan <albert@users.sf.net> is the current maintainer of the procps package.
  113.  
  114. Please send bug reports to <procps-feedback@lists.sf.net>
  115.  
  116. Linux October 5, 2007 PGREP(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement