Go to main content

手册页部分 1:用户命令

退出打印视图

更新时间: 2022年7月27日 星期三
 
 

newtask(1)

名称

newtask - 创建新任务,还可以更改项目

用法概要

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().

此外,newtask 可用来使已在运行的进程进入新创建的任务。还可以此命令形式为新任务指定项目。对于任务关键型且不能重新启动的进程,要将它们放置到新项目中,可能需要以上述方式进行指定。

在扩展记帐处于活动状态时,newtask 命令还会创建一条任务记帐记录来标记前面的系统任务的完成。

选项

支持以下选项:

–c pid

使某个正在运行的进程进入新创建的任务。还可以使用 –p 选项为新任务指定项目。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).

当为某个正在运行的进程更改项目时,将应用项目属性,这样可能会更新资源控制、资源池绑定和多 CPU 绑定 (multi-cpu binding, MCB)。setproject(3PROJECT) 手册页中提供了有关如何应用项目属性的详细信息。

此选项与 –F–l 选项不兼容。

–d

如果项目未指定 project.pool 属性,则绑定到区域的缺省池。Requires –p.这将严重破坏任何现有的池或 pset 绑定。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.若不使用此选项,如果项目未指定 project.poolproject.mcb 属性,则现有的池或 pset 绑定将保持不变。

–F

创建一个最终任务,在最终任务中,进一步的 newtasksettaskid(2) 调用将失败。在某些站点上,最终任务有助于简化查明资源消耗原因的步骤。

–l

将环境更改为用户作为新项目的成员实际重新登录时预期使用的环境。

–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.

–p

更改新任务的项目 ID,使其与给定项目名称相关联。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 –c option is used without –p, then the target process starts a new task in its current project.

–n

需要与 –p–c 选项一起使用。此选项可以在目标进程已位于项目中时避免创建新任务。仅应用项目属性。

–v

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.

操作数

支持下列操作数:

project

应当对所创建的任务使用的资源负责的项目。必须已在 nsswitch.conf(5) 中定义的项目数据库中定义了所请求的项目。

command

要作为新任务执行的命令。如果未指定命令,则调用用户的登录 shell。(如果登录 shell 不可用,则调用 /bin/sh)。

示例

示例 1 创建新 Shell

以下示例在 canada 项目中创建一个新 shell,并显示任务 ID:

example$ id -p
uid=565(gh) gid=10(staff) projid=10(default)
example$ newtask -o idfile -p canada
example$ echo $(cat idfile)
38
example$ id -p
uid=565(gh) gid=10(staff) projid=82(canada)
示例 2 运行 date 命令

以下示例在 russia 项目中运行 date 命令:

example$ newtask -p russia date
Tue Aug 31 11:12:10 PDT 1999
示例 3 更改现有进程的项目

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

example$ newtask -c 9999 -p russia

退出状态

将返回以下退出值:

0

Successful execution.

1

执行过程中发生致命错误。

2

指定的命令行选项无效。

文件

/etc/project

包含此计算机的有效项目定义的本地数据库。

/proc/pid/*

进程信息和控制文件。

属性

有关以下属性的说明,请参见 attributes(7)

属性类型
属性值
可用性
system/core-os

另请参见

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)