Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: "preg" command <- useful !!

  1. #1
    Join Date
    Jun 2002
    Posts
    648
    Rep Power
    0

    Default "preg" command <- useful !!

    Just found out about the 'preg' command. Very useful.

    This command returns the PID of the matched processes' name you've passed to it.
    You can easily combine this command with kill:
    Code:
    % kill `pgrep dummy_proc`
    ...allowing you to kill a process by name

  2. #2
    Join Date
    Aug 2002
    Posts
    6,223
    Rep Power
    0

    Default

    Quote Originally Posted by RobyG
    Just found out about the 'preg' command. Very useful.

    This command returns the PID of the matched processes' name you've passed to it.
    You can easily combine this command with kill:
    % kill `pgrep dummy_proc`
    ...allowing you to kill a process by name
    Nice!! I wish I knew of that command before. Looking up the PID before issuing the KILL command was always a pain. I assume you have to use the single quote?
    .
    PC - Ubuntu 15.04 64bit Desktop
    HP Pav G60-236US 3GB RAM Laptop, Ubuntu 15.04 64bit and Win7 Home

    "So Daddy, how come you telling me stealing not right when YOU copying DVDs? How come? How Come?"


    RIP Ramesh ...

  3. #3
    Join Date
    Jun 2002
    Posts
    648
    Rep Power
    0

    Default

    Not a single quote.
    It is really a tick (i think that is what they call it)... the one under the ~ symbol.

  4. #4
    Join Date
    Aug 2002
    Posts
    6,223
    Rep Power
    0

    Default

    Quote Originally Posted by RobyG
    Not a single quote.
    It is really a tick (i think that is what they call it)... the one under the ~ symbol.
    Gracias, señor.
    .
    PC - Ubuntu 15.04 64bit Desktop
    HP Pav G60-236US 3GB RAM Laptop, Ubuntu 15.04 64bit and Win7 Home

    "So Daddy, how come you telling me stealing not right when YOU copying DVDs? How come? How Come?"


    RIP Ramesh ...

  5. #5
    Join Date
    Aug 2002
    Posts
    3,959
    Rep Power
    25

    Default

    RobyG,

    That will make life easier.

    Thanks.

  6. #6
    Join Date
    Jul 2002
    Posts
    818
    Rep Power
    0

    Default

    If you want to kill a process by name you could use "killall -9 <prog_name>"

  7. #7
    Join Date
    Jan 2005
    Posts
    3,151
    Rep Power
    0

    Default

    I dont like killall much, its not standardized across the unix like OSes.

    Code:
    NAME
         killall - kill all active processes
    
    SYNOPSIS
         /usr/sbin/killall [ signal ]
    
    DESCRIPTION
         killall is used by shutdown(1M) to kill all active processes
         not directly related to the shutdown procedure.
    Code:
    NAME
    
      killall - Terminates all processes started by the user, except the calling
      process
    
    SYNOPSIS
    
      /usr/sbin/killall [- | [-]signal_name |  -signal_number]
    
      /usr/sbin/killall -l
    
    DESCRIPTION
    
      This command provides a convenient means of killing all processes created
      by the shell that you control.  When started by the superuser, the killall
      command kills all processes that can be terminated, except those processes
      that started it, the kernel processes, and processes 0 and 1(init).
    I remember the first time I ran killall on sunbox a few years ago... never again

  8. #8
    Join Date
    Jul 2002
    Posts
    818
    Rep Power
    0

    Default

    Was the second snippet taken from a Sun box?

  9. #9
    Join Date
    Jan 2005
    Posts
    3,151
    Rep Power
    0

    Default

    The first one was sun, the second one was OSF/1

  10. #10
    Join Date
    Jun 2003
    Posts
    273
    Rep Power
    0

    Default

    Quote Originally Posted by pogi_2nr
    I dont like killall much, its not standardized across the unix like OSes.

    I remember the first time I ran killall on sunbox a few years ago... never again
    Heh, what happened Pogi - did you kill process 1 (init) ?
    If real is what you can feel, smell, taste and see, then 'real' is simply electrical signals interpreted by your brain
    - Morpheus, "The Matrix"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •