System Administration Guide: Advanced Administration

ProcedureHow to Terminate a Process (pkill)

  1. (Optional) To terminate the process of another user, become superuser or assume an equivalent role.

  2. Obtain the process ID for the process that you want to terminate.


    $ pgrep process
    

    where process is the name of the process that you want to terminate.

    For example:


    $ pgrep netscape
    587
    566

    The process ID is displayed in the output.


    Note –

    To obtain process information on a Sun Ray, use the following commands:


    # ps -fu user
    

    This command lists all user processes.


    # ps -fu user | grep process
    

    This command locates a specific process for a user.


  3. Terminate the process.


    $ pkill [signal] process
    
    signal

    When no signal is included in the pkill command-line syntax, the default signal that is used is –15 (SIGKILL). Using the –9 signal (SIGTERM) with the pkill command ensures that the process terminates promptly. However, the –9 signal should not be used to kill certain processes, such as a database process, or an LDAP server process. The result is that data might be lost.

    process

    Is the name of the process to stop.


    Tip –

    When using the pkill command to terminate a process, first try using the command by itself, without including a signal option. Wait a few minutes to see if the process terminates before using the pkill command with the -9 signal.


  4. Verify that the process has been terminated.


    $ pgrep process
    

    The process you terminated should no longer be listed in the output of the pgrep command.