Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Wednesday, February 9, 2022



newtask - create new task and optionally change project


newtask [-p project [–d]] [-v | -o file] [-c pid | [-Fl] [command...]]


The newtask command executes the user's default shell or a specified command, placing the executed command in a new task owned by the specified project. The user's default shell is the one specified in the passwd database, and is determined using getpwnam().

Alternatively, newtask can be used to cause an already running process to enter a newly created task. A project for the new task can also be specified in this form of the command. This might be desirable for processes that are mission critical and cannot be restarted in order to put them into a new project.

In the case that extended accounting is active, the newtask command can additionally cause the creation of a task accounting record marking the completion of the preceding system task.


The following options are supported:

–c pid

Cause a running process to enter a newly created task. A project for the new task can also be specified using the –p option. The invoking user must either own the process or have the required privileges listed in setproject(3PROJECT).

If the project is being changed, the process owner must be a member of the specified project, or the invoking user must have the required privileges listed in setproject(3PROJECT).

When the project is changed for a running process, the project attributes are applied, potentially updating resource controls, resource pool binding, and multi-cpu binding (MCB). The details of how project attributes are applied is described in the setproject(3PROJECT) manpage.

This option is incompatible with the –F and –l options.


Binds to default pool of the zone if project does not specify a project.pool attribute. Requires –p. This will clobber any existing pool or pset binding. This option is useful if the target process has been manually bound to a pool or pset, a project does not specify a project.pool attribute, and the system administrator wishes to restore the default pool binding for the zone. Without this option, if a project does not specify a project.pool or project.mcb attribute, existing pool or pset bindings will remain.


Creates a finalized task, within which further newtask or settaskid(2) invocations would fail. Finalized tasks can be useful at some sites for simplifying the attribution of resource consumption.


Changes the environment to what would be expected if the user actually logged in again as a member of the new project.

–o file

Prints the system task ID to file as the new system task is started. If the file can neither be created, nor opened for writing and truncated, newtask will exit immediately without taking any further action. newtask never deletes file. This option is incompatible with the option –v.


Changes the project ID of the new task to that associated with the given project name. The invoking user must be a valid member of the requested project, or must have the required privileges listed in setproject(3PROJECT), for the command to succeed. If no project name is specified, the new task is started in the project user's current project. If –c option is used without –p, then the target process starts a new task in its current project.


Requires –p and –c options. This option avoids creating a new task if the target process is already in the project. Only project attributes are applied.


Prints the system task ID to standard error output as the new system task is started. Note that command may generate its own output to standard error. See also the –o option. This option is incompatible with the option –o.


The following operands are supported:


The project to which resource usage by the created task should be charged. The requested project must be defined in the project databases defined in nsswitch.conf(5).


The command to be executed as the new task. If no command is given, the user's login shell is invoked. (If the login shell is not available, /bin/sh is invoked.)


Example 1 Creating a New Shell

The following example creates a new shell in the canada project, displaying the task id:

example$ id -p
uid=565(gh) gid=10(staff) projid=10(default)
example$ newtask -o idfile -p canada
example$ echo $(cat idfile)
example$ id -p
uid=565(gh) gid=10(staff) projid=82(canada)
Example 2 Running the date Command

The following example runs the date command in the russia project:

example$ newtask -p russia date
Tue Aug 31 11:12:10 PDT 1999
Example 3 Changing the Project of an Existing Process

The following example changes the project of the existing process with a PID of 9999 to russia:

example$ newtask -c 9999 -p russia

Exit Status

The following exit values are returned:


Successful execution.


A fatal error occurred during execution.


Invalid command line options were specified.



Local database containing valid project definitions for this machine.


Process information and control files.


See attributes(7) for a description of the following attributes:


See Also

proc(1), execvp(2), setrctl(2), settaskid(2), setproject(3PROJECT), nsswitch.conf(5), proc(5), project(5), attributes(7), privileges(7), id(8), poolbind(8)