If you are using these facilities on a Solaris system with zones installed,
only processes in the same zone will be visible through system call interfaces that
take process IDs when these commands are run in a non-global zone.

Administering Projects and Tasks (Task Map)

Task

Description

For Instructions

View examples of commands and options used with projects and tasks.

Display task and project IDs, display various statistics for processes and projects
that are currently running on your system.

Example Commands and Command Options

This section provides examples of commands and options used with projects and
tasks.

Command Options Used With Projects and Tasks

ps Command

Use the ps command with the -o option to
display task and project IDs. For example, to view the project ID, type the following:

# ps -o user,pid,uid,projid
USER PID UID PROJID
jtd 89430 124 4113

id Command

Use the id command with the -p option to
print the current project ID in addition to the user and group IDs. If the user operand is provided, the project associated with that user's normal
login is printed:

# id -p
uid=124(jtd) gid=10(staff) projid=4113(booksite)

pgrep and pkill Commands

To match only processes with a project ID in a specific list, use the pgrep and pkill commands with the -J option:

# pgrep -J projidlist
# pkill -J projidlist

To match only processes with a task ID in a specific list, use the pgrep and pkill commands with the -T option:

# pgrep -T taskidlist
# pkill -T taskidlist

prstat Command

To display various statistics for processes and projects that are currently
running on your system, use the prstat command with the -J option:

Using cron and su With Projects and Tasks

cron Command

The cron command issues a settaskid to
ensure that each cron, at, and batch job executes in a separate task, with the appropriate default project for
the submitting user. The at and batch commands
also capture the current project ID, which ensures that the project ID is restored
when running an at job.

su Command

The su command joins the target user's default project by
creating a new task, as part of simulating a login.

To switch the user's default project by using the su command,
type the following:

# su user

Administering Projects

How to Define a Project and View the Current
Project

This example shows how to use the projadd command to add
a project entry and the projmod command to alter that entry.

Log in as user mark and
type projects to view the projects that are assigned to this user.

# su - mark
# projects
default

How to Validate the Contents of the /etc/project File

If no editing options are given, the projmod command validates
the contents of the project file.

To validate a NIS map, as superuser, type the following:

# ypcat project | projmod -f —

Note –

The ypcat project | projmod -f — command is not
yet implemented.

To check the syntax of the /etc/project file, type the
following:

# projmod -n

How to Obtain Project Membership Information

Use the id command with the -p flag to display
the current project membership of the invoking process.

$ id -p
uid=100(mark) gid=1(other) projid=3(default)

How to Create a New Task

Log in as a member of the destination project, booksite.

Create a new task in the booksite project by using the newtask command with the -v (verbose) option to obtain the system task ID.

machine% newtask -v -p booksite
16

The execution of newtask creates a new task in the specified
project, and places the user's default shell in this task.

View the current project membership of the
invoking process.

machine% id -p
uid=100(mark) gid=1(other) projid=4113(booksite)

The process is now a member of the new project.

How to Move a Running Process Into a New Task

This example shows how to associate a running process with a different task
and new project. To perform this action, you must either be superuser, or be the owner
of the process and be a member of the new project.

If you are the owner of the process or a member of the new project, you
can skip this step.

Obtain the process ID of the book_catalog process.

# pgrep book_catalog
8100

Associate process 8100 with
a new task ID in the booksite project.

# newtask -v -p booksite -c 8100
17

The -c option specifies that newtask operate
on the existing named process.

Confirm the task to process ID mapping.

# pgrep -T 17
8100

Editing and Validating Project Attributes

You can use the projadd and projmod project
database administration commands to edit project attributes.

The -K option specifies a replacement list of attributes. Attributes
are delimited by semicolons (;). If the -K option
is used with the -a option, the attribute or attribute value is added.
If the -K option is used with the -r option, the attribute
or attribute value is removed. If the -K option is used with the -s option, the attribute or attribute value is substituted.

How to Add Attributes and Attribute Values to Projects

Use the projmod command with the -a and -K options to add values to a project attribute. If the attribute does not
exist, it is created.