Go to main content

Administering Resource Management in Oracle® Solaris 11.4

Exit Print View

Updated: February 2021
 
 

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

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, similar to the following:

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

% prstat -J
   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP       
 12905 root     4472K 3640K cpu0    59    0   0:00:01 0.4% prstat/1
   829 root       43M   33M sleep   59    0   0:36:23 0.1% Xorg/1
…
   142 daemon   7736K 5224K sleep   59    0   0:00:00 0.0% kcfd/3
    43 root     3036K 2020K sleep   59    0   0:00:00 0.0% dlmgmtd/5
   405 root     6824K 5400K sleep   59    0   0:00:18 0.0% hald/5
PROJID    NPROC  SWAP   RSS MEMORY      TIME  CPU PROJECT                     
     1        4 4728K   19M   0.9%   0:00:01 0.4% user.root                   
     0      111  278M  344M    17%   1:15:02 0.1% system                      
    10        2 1884K 9132K   0.4%   0:00:00 0.0% group.staff                 
     3        3 1668K 6680K   0.3%   0:00:00 0.0% default                     

Total: 120 processes, 733 lwps, load averages: 0.01, 0.00, 0.00

To display various statistics for processes and tasks that are currently running on your system, use the prstat command with the –T option.

% prstat -T
       PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP       
 12907 root     4488K 3588K cpu0    59    0   0:00:00 0.3% prstat/1
   829 root       43M   33M sleep   59    0   0:36:24 0.1% Xorg/1
…
   311 root     3488K 2512K sleep   59    0   0:00:00 0.0% picld/4
   409 root     4356K 2768K sleep   59    0   0:00:00 0.0% hald-addon-cpuf/1
TASKID    NPROC  SWAP   RSS MEMORY      TIME  CPU PROJECT                     
  1401        2 2540K 8120K   0.4%   0:00:00 0.3% user.root                   
    94       15   84M  162M   7.9%   0:59:37 0.1% system                      
   561        1   37M   24M   1.2%   0:02:06 0.0% system                      
     0        2    0K    0K   0.0%   0:02:47 0.0% system                      
    46        1 4224K 5524K   0.3%   0:00:38 0.0% system                      
Total: 120 processes, 733 lwps, load averages: 0.01, 0.00, 0.00

Note -  The –J and –T options cannot be used together.

ps Command

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

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

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, type the following command:

$ su - user