Go to main content

Administering Resource Management in Oracle® Solaris 11.3

Exit Print View

Updated: March 2018
 
 

Example Options for Projects and Tasks

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 projid-list
# pkill -J projid-list

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

# pgrep -T taskid-list
# pkill -T taskid-list

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
   890 gdm        88M   26M sleep   59    0   0:22:22 0.0% gdm-simple-gree/1
   686 root     3584K 2756K sleep   59    0   0:00:34 0.0% automountd/4
     5 root        0K    0K sleep   99  -20   0:02:43 0.0% zpool-rpool/138
  9869 root       44M   17M sleep   59    0   0:02:06 0.0% poold/9
   804 root     7104K 5968K sleep   59    0   0:01:28 0.0% intrd/1
   445 root     7204K 4680K sleep   59    0   0:00:38 0.0% nscd/33
   881 gdm      7140K 5912K sleep   59    0   0:00:06 0.0% gconfd-2/1
   164 root     2572K 1648K sleep   59    0   0:00:00 0.0% pfexecd/3
   886 gdm      7092K 4920K sleep   59    0   0:00:00 0.0% bonobo-activati/2
    45 netcfg   2252K 1308K sleep   59    0   0:00:00 0.0% netcfgd/2
   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
   890 gdm        88M   26M sleep   59    0   0:22:22 0.0% gdm-simple-gree/1
  9869 root       44M   17M sleep   59    0   0:02:06 0.0% poold/9
     5 root        0K    0K sleep   99  -20   0:02:43 0.0% zpool-rpool/138
   445 root     7204K 4680K sleep   59    0   0:00:38 0.0% nscd/33
   881 gdm      7140K 5912K sleep   59    0   0:00:06 0.0% gconfd-2/1
   164 root     2572K 1648K sleep   59    0   0:00:00 0.0% pfexecd/3
   886 gdm      7092K 4920K sleep   59    0   0:00:00 0.0% bonobo-activati/2
    45 netcfg   2252K 1308K sleep   59    0   0:00:00 0.0% netcfgd/2
   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
   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.

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