termtask command

Use the termtask command to terminate a task.

Synopsis

termtask [--help]

termtask -r {gui | ssh} -s session_id -t {task_id | all}

Description

The termtask command terminates a user's task that is running on the system.

Tip: You can use the lslogon command to list information about the users logged on to the system and the tasks that they are running.

Options

--help
Displays detailed information about the command, including the syntax, a description of the command, a description of the options and operands, error codes, and examples.
-r gui | ssh
Specifies the type of task to terminate.
gui
Specifies to terminate console user interface tasks.
ssh
Specifies to terminate SSH tasks.
-s session_id
Specifies the session ID of the user that is running the task to terminate. To terminate a console interface task (gui), use this option to specify the session ID of the user. To terminate an SSH task (ssh), use this option to specify the TTY ID of the user.
-t task_id | all
Specifies the task or tasks to terminate.
task_id
Specifies the ID of the task. To terminate a console interface task (gui), specify the task ID of the task to terminate. To terminate an SSH task (ssh), specify the process ID (PID) of the task to terminate.
all
Specifies that all tasks that the user associated with the session is running be terminated. After the tasks are terminated, the user is logged off.

Exit status

The following codes are returned by this command.
  • 0: The operation completed.
  • 1: A usage error occurred.
  • 2: The command or bundle was not found.
  • 3: The command was not performed because either authentication failed or you are not authorized to perform the action.

Examples

  1. Terminate a task

    This example illustrates how to use the lslogon command to display the user and task information, and then how to use the termtask command to terminate an SSH task that a user who is remotely logged on to the system is running.

    Use the following command to display the user and task information.

    lslogon -r ssh -t

    In this example, assume that the output of this command shows a TTY ID of "pts/4", and an SSH task process ID of "11655"

    Using this information, pass the session_id (TTY ID) and task_id (process ID) values to the termtask command.

    termtask -r ssh -s pts/4 -t 11655