SO305 - Process Management and Process Scheduling

A process is a binary file that is loaded into memory and executed. Everything you do in Solaris generates a process. A process is accompagnied by an environnment which, amongst other data, contains the following information:

A unique process ID (PID),

The unique ID of the parent process (PPID),

The unique user ID of the user who generated the process (UID),

The unique group ID of the group to which the process is attached (GID),

The processing time,

The process priority,

The current working directory,

The list of open files.

Process environnement data is stored in the /proc directory.

The /proc File System

The /proc directory contains virtual files and directories. File content is created dynamically when consulted and only root can view all the data within /proc.

Start by taking a look at all the directories containing digits:

root@solaris:~# cd /proc; ls -d [0-9]*
0 1015 1119 118 1664 191 235 3609 3644 3653 3668 3685 3722 3742 42 5770 5893 6123 6180 6236 679 85 895 936 979
1 1016 1122 13 1665 1992 237 3620 3645 3655 3674 3688 3723 3743 4985 5774 5906 6136 6181 6242 7 874 896 941 982
1002 104 1129 1406 1666 2 241 3633 3647 3657 3675 3698 3725 3782 5 5804 5960 6165 6199 6255 8 881 898 943 985
1012 11 1138 1456 1667 203 3 3636 3648 3658 3679 3700 3738 3784 50 5834 5968 6173 6201 6274 814 890 899 95 996
1013 1106 1143 1495 1668 2122 3579 3640 3650 3660 3682 3709 3739 3786 5614 5843 6 6174 6216 637 818 891 932 957
1014 1109 1159 1661 1822 225 3608 3643 3652 3661 3683 3720 3741 413 570 5889 6090 6178 6227 6736 823 892 934 978

Each of the above directories refers to a PID and contains all the necessary process environnement information.

Process Types

There are three types of processes

interactive - a process launched in a terminal either in the foreground or the background,

batch - a process launched by the system at a specific time,

daemon - a process that has no parent terminal.

A process can be in one of 9 process states:

Process State	Description
New	The process' initial state when launched
User Mode	The process executes in user mode
Kernel Mode	The process executes in kernel mode
New	The process' initial state when launched
waiting	The process is waiting for a resource other than the processor
sleeping	The process is sleeping
runnable	The process has everything it needs to run except the processor
swap	The process is sleeping in swap
elected	The process has control of the processor

Managing Processes

The ps Command

The output of the ps caommand shows those processes generated by the user attached to the terminal:

root@solaris:~# ps PID TTY TIME CMD 6771 pts/1 0:00 ps 3742 pts/1 0:00 su 3743 pts/1 0:00 bash

Used with the -f switch, the command shows the Process Table:

root@solaris:~# ps -f
UID PID PPID C STIME TTY TIME CMD
root 6772 3743 0 15:03:08 pts/1 0:00 ps -f
root 3742 3741 0 Dec 15 pts/1 0:00 su -
root 3743 3742 0 Dec 15 pts/1 0:00 -bash

The column headers in the above output are defined as follows:

UID	User ID
PID	Process Indentification
PPID	Parent Process ID
C	Priority
STIME	Start Time
TTY	Terminal
TIME	Duration
CMD	Command

To see all the running processes, add the -e switch:

root@solaris:~# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 0 0 0 Dec 15 ? 0:04 sched
root 5 0 0 Dec 15 ? 0:27 zpool-rpool
root 6 0 0 Dec 15 ? 0:02 kmem_task
root 1 0 0 Dec 15 ? 0:00 /usr/sbin/init
root 2 0 0 Dec 15 ? 0:00 pageout
root 3 0 0 Dec 15 ? 0:13 fsflush
root 7 0 0 Dec 15 ? 0:00 intrd
root 8 0 0 Dec 15 ? 0:00 vmtasks
root 874 1 0 Dec 15 ? 0:00 /usr/sbin/cron
root 11 1 0 Dec 15 ? 0:03 /lib/svc/bin/svc.startd
root 13 1 0 Dec 15 ? 0:13 /lib/svc/bin/svc.configd
root 203 1 0 Dec 15 ? 0:00 /usr/lib/zones/zonestatd
pkg5srv 1667 1661 0 Dec 15 ? 0:00 /usr/apache2/2.2/bin/64/httpd.worker -f /system/volatile/pkg/sysrepo/sysrepo_ht
root 118 1 0 Dec 15 ? 0:00 /usr/lib/pfexecd
pkg5srv 1495 1 0 Dec 15 ? 0:07 /usr/apache2/2.2/bin/htcacheclean -d20160 -i -l 2048M -n -p /var/cache/pkg/sysr
netcfg 42 1 0 Dec 15 ? 0:00 /lib/inet/netcfgd
root 679 1 0 Dec 15 ? 0:00 /usr/lib/picl/picld
root 1106 1 0 Dec 15 ? 0:00 /usr/lib/devchassis/devchassisd
trainee 3650 1 0 Dec 15 ? 0:00 /usr/lib/bonobo-activation-server --ac-activate --ior-output-fd=21
dladm 50 1 0 Dec 15 ? 0:00 /usr/sbin/dlmgmtd
daemon 85 1 0 Dec 15 ? 0:00 /lib/crypto/kcfd
root 104 1 0 Dec 15 ? 0:00 /lib/inet/in.mpathd
netadm 95 1 0 Dec 15 ? 0:00 /lib/inet/ipmgmtd
daemon 881 1 0 Dec 15 ? 0:00 /usr/sbin/rpcbind
root 637 1 0 Dec 15 ? 0:00 /sbin/dhcpagent
root 818 0 0 Dec 15 ? 0:00 zpool-mypool
root 957 1 0 Dec 15 ? 0:00 /usr/sbin/syslogd
root 934 1 0 Dec 15 ? 2:09 /usr/lib/fm/fmd/fmd
root 898 1 0 Dec 15 ? 0:00 /usr/lib/autofs/automountd
trainee 3648 3579 0 Dec 15 ? 0:01 nautilus
root 932 1 0 Dec 15 ? 0:02 /usr/bin/VBoxService
root 237 1 0 Dec 15 ? 0:00 /usr/lib/rad/rad -sp
root 225 1 0 Dec 15 ? 0:00 /usr/lib/sysevent/syseventd
root 814 1 0 Dec 15 ? 0:03 /usr/sbin/nscd
root 235 1 0 Dec 15 ? 0:00 /usr/sbin/vbiosd
trainee 3644 3579 0 Dec 15 ? 0:05 metacity
pkg5srv 1666 1661 0 Dec 15 ? 0:00 /usr/apache2/2.2/bin/64/httpd.worker -f /system/volatile/pkg/sysrepo/sysrepo_ht
root 413 1 0 Dec 15 ? 0:01 /usr/lib/devfsadm/devfsadmd
trainee 3658 3579 0 Dec 15 ? 0:01 /usr/bin/python2.6 /usr/lib/updatemanagernotifier
root 823 1 0 Dec 15 ? 0:00 /lib/svc/method/iscsid
root 191 1 0 Dec 15 ? 0:00 /usr/lib/utmpd
root 996 895 0 Dec 15 ? 0:00 /usr/lib/hal/hald-addon-storage
root 241 1 0 Dec 15 ? 0:00 /usr/lib/dbus-daemon --system
netadm 570 1 0 Dec 15 ? 0:00 /lib/inet/nwamd
root 892 1 0 Dec 15 ? 0:01 /usr/lib/hal/hald --daemon=yes
noaccess 1129 1 0 Dec 15 ? 0:00 /usr/lib/fm/notify/asr-notify
pkg5srv 1668 1661 0 Dec 15 ? 0:00 /usr/apache2/2.2/bin/64/httpd.worker -f /system/volatile/pkg/sysrepo/sysrepo_ht
root 936 1 0 Dec 15 ? 0:00 /usr/lib/ssh/sshd
root 1122 1 0 Dec 15 ? 0:00 /usr/sbin/gdm-binary
root 941 895 0 Dec 15 ? 0:00 /usr/lib/hal/hald-addon-cpufreq
daemon 890 1 0 Dec 15 ? 0:00 /usr/lib/nfs/nfsmapid
root 891 1 0 Dec 15 ? 0:00 /usr/lib/inet/inetd start
root 899 898 0 Dec 15 ? 0:00 /usr/lib/autofs/automountd
root 895 892 0 Dec 15 ? 0:00 hald-runner
root 896 1 0 Dec 15 ? 0:00 /usr/sbin/console-kit-daemon
root 943 895 0 Dec 15 ? 0:01 /usr/lib/hal/hald-addon-acpi
root 985 11 0 Dec 15 console 0:00 /usr/sbin/ttymon -g -d /dev/console -l console -T sun-color -m ldterm,ttcompat
root 979 1 0 Dec 15 ? 0:00 /usr/sbin/auditd
root 982 1 0 Dec 15 ? 0:00 /usr/lib/sendmail -bl -q15m
smmsp 978 1 0 Dec 15 ? 0:00 /usr/lib/sendmail -Ac -q15m
trainee 1159 1143 1 Dec 15 vt/7 1:59 /usr/bin/Xorg :0 -nolisten tcp -br -novtswitch -auth /tmp/gdm-auth-cookies-DOaq
root 6255 1 0 Dec 15 ? 0:00 /usr/lib/inet/in.ndpd
root 1002 1 0 Dec 15 vt/1 0:00 /usr/lib/vtdaemon -c 16
daemon 6181 1 0 Dec 15 ? 0:00 /usr/lib/nfs/nfsmapid
root 1012 11 0 Dec 15 vt/4 0:00 /usr/sbin/ttymon -g -d /dev/vt/4 -l console -m ldterm,ttcompat -h -p solaris.fe
root 1013 11 0 Dec 15 vt/2 0:00 /usr/sbin/ttymon -g -d /dev/vt/2 -l console -m ldterm,ttcompat -h -p solaris.fe
root 1014 11 0 Dec 15 vt/6 0:00 /usr/sbin/ttymon -g -d /dev/vt/6 -l console -m ldterm,ttcompat -h -p solaris.fe
root 1015 11 0 Dec 15 vt/5 0:00 /usr/sbin/ttymon -g -d /dev/vt/5 -l console -m ldterm,ttcompat -h -p solaris.fe
root 1016 11 0 Dec 15 vt/3 0:00 /usr/sbin/ttymon -g -d /dev/vt/3 -l console -m ldterm,ttcompat -h -p solaris.fe
noaccess 1138 1 0 Dec 15 ? 0:00 /usr/lib/fm/notify/smtp-notify
root 1119 1 0 Dec 15 ? 0:00 /usr/lib/rmvolmgr -s
root 4985 1 0 Dec 15 ? 0:00 zsched
root 1406 1 0 Dec 15 ? 0:00 /usr/sbin/cupsd -C /etc/cups/cupsd.conf
root 6201 5770 0 Dec 15 zoneconsole 0:00 /usr/sbin/ttymon -g -d /dev/console -l console -T vt100 -m ldterm,ttcompat -h -
root 1109 1 0 Dec 15 ? 0:00 /usr/lib/inet/in.ndpd
root 1143 1122 0 Dec 15 ? 0:00 /usr/lib/gdm-simple-slave --display-id /org/gnome/DisplayManager/Display1
gdm 1456 1 0 Dec 15 ? 0:00 /usr/bin/dbus-launch --exit-with-session
trainee 3645 3579 0 Dec 15 ? 0:02 gnome-panel
trainee 3652 1 0 Dec 15 ? 0:05 /usr/lib/wnck-applet --oaf-activate-iid=OAFIID:GNOME_Wncklet_Factory --oaf-ior-
trainee 3653 3579 0 Dec 15 ? 0:00 /usr/lib/nwam-manager
netadm 5893 1 0 Dec 15 ? 0:00 /lib/inet/ipmgmtd
root 2122 1 0 Dec 15 ? 0:00 /usr/lib/ocm/ccr/bin/nmz
trainee 3609 1 0 Dec 15 ? 0:00 /usr/lib/dbus-daemon --fork --print-pid 6 --print-address 8 --session
root 6773 3743 0 15:04:31 pts/1 0:00 ps -ef
pkg5srv 1665 1661 0 Dec 15 ? 0:00 /usr/apache2/2.2/bin/64/httpd.worker -f /system/volatile/pkg/sysrepo/sysrepo_ht
trainee 3579 1992 0 Dec 15 ? 0:00 gnome-session
trainee 3643 1 0 Dec 15 ? 0:00 /usr/lib/gvfsd
trainee 3620 3579 0 Dec 15 ? 0:00 /usr/bin/ssh-agent -- gnome-session
trainee 3633 1 0 Dec 15 ? 0:02 /usr/lib/gconfd-2
trainee 3647 1 0 Dec 15 ? 0:00 /usr/lib/gvfs-hal-volume-monitor
root 1664 1 0 Dec 15 ? 0:00 /usr/lib/zones/zoneproxyd
trainee 3608 1 0 Dec 15 ? 0:00 dbus-launch --exit-with-session --sh-syntax
root 1661 1 0 Dec 15 ? 0:00 /usr/apache2/2.2/bin/64/httpd.worker -f /system/volatile/pkg/sysrepo/sysrepo_ht
root 1822 1 0 Dec 15 ? 0:00 zoneadmd -z myzone
netadm 5960 1 0 Dec 15 ? 0:07 /lib/inet/nwamd
trainee 3636 1 0 Dec 15 ? 0:00 /usr/bin/gnome-keyring-daemon --start --components=pkcs11
trainee 3640 1 0 Dec 15 ? 0:03 /usr/lib/gnome-settings-daemon
root 1992 1143 0 Dec 15 ? 0:00 /usr/lib/gdm-session-worker
trainee 3657 1 0 Dec 15 ? 0:00 /usr/lib/gvfsd-trash --spawner :1.9 /org/gtk/gvfs/exec_spaw/0
root 6136 1 0 Dec 15 ? 0:04 /usr/sbin/nscd
root 6090 1 0 Dec 15 ? 0:00 /usr/lib/zones/zoneproxy-client -s localhost:1008
root 6216 1 0 Dec 15 ? 0:01 /usr/sbin/syslogd
root 6173 1 0 Dec 15 ? 0:00 /usr/lib/autofs/automountd
root 6123 1 0 Dec 15 ? 0:00 /usr/sbin/cron
root 6178 1 0 Dec 15 ? 0:00 /usr/lib/inet/inetd start
trainee 6274 1 2 Dec 15 ? 1:40 gedit
root 6199 1 0 Dec 15 ? 0:00 /usr/lib/ssh/sshd
daemon 5834 1 0 Dec 15 ? 0:00 /lib/crypto/kcfd
root 5968 1 0 Dec 15 ? 0:00 /sbin/dhcpagent
root 5614 4985 0 Dec 15 ? 0:00 /usr/sbin/init
trainee 3655 1 0 Dec 15 ? 0:00 /usr/lib/trashapplet --oaf-activate-iid=OAFIID:GNOME_Panel_TrashApplet_Factory
root 5906 1 0 Dec 15 ? 0:00 /lib/inet/in.mpathd
root 5843 1 0 Dec 15 ? 0:00 /usr/lib/pfexecd
trainee 6736 1 0 Dec 15 ? 0:01 nautilus --no-desktop /home/trainee
root 6174 6173 0 Dec 15 ? 0:00 /usr/lib/autofs/automountd
root 6180 1 0 Dec 15 ? 0:00 /usr/lib/fm/fmd/fmd
root 5889 1 0 Dec 15 ? 0:00 /usr/lib/utmpd
root 5770 1 0 Dec 15 ? 0:01 /lib/svc/bin/svc.startd
trainee 3660 3579 0 Dec 15 ? 0:00 python2.6 /usr/lib/system-config-printer/applet.py
trainee 3722 1 0 Dec 15 ? 0:00 /usr/lib/notification-daemon
trainee 3679 1 0 Dec 15 ? 0:00 /usr/bin/VBoxClient --display
daemon 6165 1 0 Dec 15 ? 0:00 /usr/sbin/rpcbind
netcfg 5804 1 0 Dec 15 ? 0:00 /lib/inet/netcfgd
trainee 3661 3579 0 Dec 15 ? 1:12 java -Djava.security.policy=/usr/share/vpanels/java.policy com.oracle.solaris.v
trainee 3739 3738 0 Dec 15 ? 0:00 gnome-pty-helper
trainee 3675 1 0 Dec 15 ? 0:00 /usr/bin/VBoxClient --clipboard
trainee 3700 1 0 Dec 15 ? 0:00 /usr/lib/notification-area-applet --oaf-activate-iid=OAFIID:GNOME_NotificationA
trainee 3674 3579 0 Dec 15 ? 0:03 /usr/bin/xscreensaver -nosplash
trainee 3683 1 0 Dec 15 ? 0:26 /usr/bin/VBoxClient --draganddrop
trainee 3668 3579 0 Dec 15 ? 0:01 gnome-power-manager
trainee 3685 3579 0 Dec 15 ? 0:00 gnome-volume-control-applet
trainee 3682 1 0 Dec 15 ? 0:00 /usr/bin/VBoxClient --seamless
trainee 3698 1 0 Dec 15 ? 0:01 /usr/lib/clock-applet --oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory --oaf
trainee 3688 3579 0 Dec 15 ? 0:01 python2.6 /usr/lib/time-slider-notify
trainee 3720 1 0 Dec 15 ? 0:00 /usr/lib/gvfsd-metadata
trainee 3738 1 0 Dec 15 ? 0:05 gnome-terminal
trainee 3723 237 0 Dec 15 ? 0:00 /usr/lib/rad/rad -m /usr/lib/rad/transport -m /usr/lib/rad/protocol -m /usr/lib
trainee 3709 1 0 Dec 15 ? 0:00 /usr/bin/pulseaudio --start
trainee 3725 1 1 Dec 15 ? 11:40 /usr/bin/firefox
root 3742 3741 0 Dec 15 pts/1 0:00 su -
trainee 3741 3738 0 Dec 15 pts/1 0:00 bash
root 3743 3742 0 Dec 15 pts/1 0:00 -bash
root 5774 1 0 Dec 15 ? 0:07 /lib/svc/bin/svc.configd
trainee 3784 1 0 Dec 15 ? 0:02 evince file:///tmp/Solaris_Zones_Tutorial.pdf
trainee 3782 1 0 Dec 15 ? 0:00 /usr/lib/gam_server
trainee 3786 1 0 Dec 15 ? 0:00 /usr/lib/evinced
smmsp 6227 1 0 Dec 15 ? 0:00 /usr/lib/sendmail -Ac -q15m
root 6236 1 0 Dec 15 ? 0:00 /usr/lib/sendmail -bl -q15m
root 6242 1 0 Dec 15 ? 0:00 /usr/lib/fm/notify/smtp-notify

The top Command

The ps command, although useful, only gives a snapshot view of the processes running at the time the command was executed. To get a continual view of what is running you can use the top command:

last pid: 6807; load avg: 0.21, 0.19, 0.17; up 2+08:33:55 15:59:00
141 processes: 140 sleeping, 1 on cpu
CPU states: 93.2% idle, 4.1% user, 2.7% kernel, 0.0% iowait, 0.0% swap
Kernel: 1111 ctxsw, 15 trap, 879 intr, 3744 syscall, 4 flt
Memory: 2048M phys mem, 74M free mem, 1024M total swap, 1024M free swap
PID USERNAME NLWP PRI NICE SIZE RES STATE TIME CPU COMMAND
934 root 28 59 0 38M 6224K sleep 4:42 2.30% fmd
3738 trainee 2 54 0 129M 18M sleep 0:07 0.87% gnome-terminal
3725 trainee 19 49 0 533M 216M sleep 12:58 0.82% firefox
1159 trainee 3 59 0 170M 152M sleep 2:10 0.45% Xorg
3661 trainee 23 59 0 235M 116M sleep 1:25 0.24% java
3683 trainee 3 59 0 13M 724K sleep 0:31 0.10% VBoxClient
6806 root 1 59 0 4432K 2848K cpu/1 0:00 0.08% top
5960 netadm 7 59 0 5344K 3504K sleep 0:08 0.03% nwamd
3644 trainee 1 59 0 31M 13M sleep 0:05 0.02% metacity
3698 trainee 1 59 0 32M 8904K sleep 0:00 0.02% clock-applet
13 root 18 59 0 23M 13M sleep 0:13 0.02% svc.configd
3640 trainee 1 59 0 143M 21M sleep 0:03 0.01% gnome-settings-
6136 root 27 59 0 5808K 3084K sleep 0:04 0.01% nscd
932 root 7 59 0 11M 600K sleep 0:02 0.01% VBoxService
6216 root 11 59 0 3964K 1080K sleep 0:01 0.01% syslogd
3688 trainee 1 59 0 133M 13M sleep 0:01 0.00% isapython2.6
3658 trainee 1 12 19 61M 25M sleep 0:01 0.00% updatemanagerno
104 root 1 59 0 9692K 388K sleep 0:00 0.00% in.mpathd
1495 pkg5srv 1 59 0 5272K 1240K sleep 0:07 0.00% htcacheclean
3674 trainee 1 59 0 14M 2892K sleep 0:03 0.00% xscreensaver
1665 pkg5srv 24 59 0 21M 240K sleep 0:00 0.00% httpd.worker
982 root 1 59 0 6224K 1216K sleep 0:00 0.00% sendmail
3668 trainee 1 59 0 128M 9484K sleep 0:00 0.00% gnome-power-man
1661 root 1 59 0 14M 204K sleep 0:00 0.00% httpd.worker
6236 root 1 59 0 6164K 1900K sleep 0:00 0.00% sendmail
3653 trainee 2 59 0 128M 9724K sleep 0:00 0.00% nwam-manager
5968 root 1 59 0 2592K 1232K sleep 0:00 0.00% dhcpagent
1138 noaccess 4 59 0 10M 1736K sleep 0:00 0.00% smtp-notify
637 root 1 59 0 9408K 484K sleep 0:00 0.00% dhcpagent

The default refresh interval is 3 seconds. To make it 1 second, use top's s command:

last pid: 6807; load avg: 0.17, 0.18, 0.17; up 2+08:38:55 16:04:00
141 processes: 138 sleeping, 2 running, 1 on cpu
CPU states: 95.1% idle, 2.9% user, 2.0% kernel, 0.0% iowait, 0.0% swap
Kernel: 1084 ctxsw, 10 trap, 894 intr, 4709 syscall, 5 flt
Memory: 2048M phys mem, 69M free mem, 1024M total swap, 1024M free swap
Seconds to delay: 1
PID USERNAME NLWP PRI NICE SIZE RES STATE TIME CPU COMMAND
3725 trainee 19 49 0 533M 216M sleep 13:05 1.05% firefox
6274 trainee 1 49 0 141M 28M sleep 2:04 0.80% gedit
1159 trainee 3 59 0 170M 152M sleep 2:11 0.71% Xorg
3652 trainee 1 59 0 129M 13M sleep 0:05 0.26% wnck-applet
3661 trainee 23 59 0 235M 116M run 1:26 0.23% java
3738 trainee 2 59 0 129M 18M sleep 0:08 0.21% gnome-terminal
3683 trainee 3 59 0 13M 724K run 0:31 0.09% VBoxClient
...

Use the M key to sort the processes in descending order of memery usage:

last pid: 8942; load avg: 0.12, 0.15, 0.11; up 3+05:39:51 13:04:56
145 processes: 143 sleeping, 1 zombie, 1 on cpu
CPU states: 89.4% idle, 6.6% user, 4.0% kernel, 0.0% iowait, 0.0% swap
Kernel: 1037 ctxsw, 5616 trap, 828 intr, 6520 syscall, 5 fork, 3960 flt
Memory: 2048M phys mem, 197M free mem, 1024M total swap, 1024M free swap
PID USERNAME NLWP PRI NICE SIZE RES STATE TIME CPU COMMAND
3725 trainee 22 49 0 519M 168M sleep 25:28 0.45% firefox
3661 trainee 23 59 0 227M 149M sleep 2:58 0.18% java
3685 trainee 1 59 0 191M 8008K sleep 0:00 0.00% gnome-volume-co
1159 trainee 3 59 0 169M 151M sleep 3:59 0.30% Xorg
3645 trainee 2 59 0 150M 35M sleep 0:05 0.00% gnome-panel
3648 trainee 1 49 0 147M 28M sleep 0:01 0.00% nautilus
3640 trainee 1 59 0 143M 22M sleep 0:06 0.00% gnome-settings-
...

The fg and bg Commands

You can launch a process either in the foreground or the background when using bash or ksh. A process running in the background is asynchonous whilst a process in the foreground is synchronous.

Execute the following command:

root@solaris:~# sleep 9999 &
[1] 6790

In the above output you can see a job number between square brackets followed by the PID. The job number is specific to the terminal in which the cammand is executed.

At any point in time, you can display a list of running jobs by using the jobs command:

root@solaris:~# jobs -l
[1]+ 6790 Running sleep 9999 &

Note the + sign between the job number and PID. This indicates that the job is the last job to have been worked on. A - sign indicates that the job was the second to last job thta was worked on.

If you are running a job in the foreground and you wish to swap it to the background, you first need to pause the process. Pausing a process in Solaris 11 is acheived using ^Z as shown by the output of the follwing command:

root@solaris:~# stty -a
speed 38400 baud;
rows = 36; columns = 168; ypixels = 0; xpixels = 0;
csdata ?
eucw 1:0:0:0, scrw 1:0:0:0
intr = ^c; quit = ^\; erase = ^?; kill = ^u;
eof = ^d; eol = -^?; eol2 = -^?; swtch = <undef>;
start = ^q; stop = ^s; susp = ^z; dsusp = ^y;
rprnt = ^r; flush = ^o; werase = ^w; lnext = ^v;
-parenb -parodd cs8 -cstopb hupcl cread -clocal -loblk -crtscts -crtsxoff -parext
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iuclc
ixon ixany -ixoff imaxbel
isig icanon -xcase echo echoe echok -echonl -noflsh
-tostop echoctl -echoprt echoke -defecho -flusho -pendin iexten
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel

To understand how ths works, execute the following command:

root@solaris:~# sleep 1234

Now pause the process with ^Z :

root@solaris:~# sleep 1234
^Z
[2]+ Stopped sleep 1234
root@solaris:~# jobs -l
[1]- 6790 Running sleep 9999 &
[2]+ 6794 Stopped (user) sleep 1234

Now the process is paused you can switch it to the background using the bg command:

root@solaris:~# bg %2
[2]+ sleep 1234 &
root@solaris:~# jobs -l
[1]- 6790 Running sleep 9999 &
[2]+ 6794 Running sleep 1234 &

Note that when the job is sent to the background, it automatically starts to run.

When you want to switch the process back to the foreground, you must again pause it. However, in this case, you cannot use ^Z. Instead you need to send a signal to the process using the kill command:

root@solaris:~# kill -l
1) SIGHUP	2) SIGINT	3) SIGQUIT	4) SIGILL	5) SIGTRAP
6) SIGABRT	7) SIGEMT	8) SIGFPE	9) SIGKILL	10) SIGBUS
11) SIGSEGV	12) SIGSYS	13) SIGPIPE	14) SIGALRM	15) SIGTERM
16) SIGUSR1	17) SIGUSR2	18) SIGCHLD	19) SIGPWR	20) SIGWINCH
21) SIGURG	22) SIGIO	23) SIGSTOP	24) SIGTSTP	25) SIGCONT
26) SIGTTIN	27) SIGTTOU	28) SIGVTALRM	29) SIGPROF	30) SIGXCPU
31) SIGXFSZ	32) SIGWAITING	33) SIGLWP	34) SIGFREEZE	35) SIGTHAW
36) SIGCANCEL	37) SIGLOST	38) SIGXRES	39) SIGJVM1	40) SIGJVM2
41) SIGRTMIN	42) SIGRTMIN+1	43) SIGRTMIN+2	44) SIGRTMIN+3	45) SIGRTMIN+4
46) SIGRTMIN+5	47) SIGRTMIN+6	48) SIGRTMIN+7	49) SIGRTMIN+8	50) SIGRTMIN+9
51) SIGRTMIN+10	52) SIGRTMIN+11	53) SIGRTMIN+12	54) SIGRTMIN+13	55) SIGRTMIN+14
56) SIGRTMIN+15	57) SIGRTMAX-15	58) SIGRTMAX-14	59) SIGRTMAX-13	60) SIGRTMAX-12
61) SIGRTMAX-11	62) SIGRTMAX-10	63) SIGRTMAX-9	64) SIGRTMAX-8	65) SIGRTMAX-7
66) SIGRTMAX-6	67) SIGRTMAX-5	68) SIGRTMAX-4	69) SIGRTMAX-3	70) SIGRTMAX-2
71) SIGRTMAX-1	72) SIGRTMAX

The signal we need to send is the SIGSTOP:

oot@solaris:~# kill -23 %2
root@solaris:~# jobs -l
[1]- 6790 Running sleep 9999 &
[2]+ 6794 Stopped (signal) sleep 1234

Now you can bring the process to the forground using the fg command:

root@solaris:~# fg %2
sleep 1234
^C

The wait command

The wait command transforms an asynchronous command into a synchronous command.

For example:

root@solaris:~# jobs -l
[1]+ 6790 Running sleep 9999 &
root@solaris:~# wait %1
^C
root@solaris:~# jobs -l
[1]+ 6790 Running sleep 9999 &

The prioctnl Command

Whilst the nice command still exists in Solaris 11, its use is deprecated and it has been included only for backward compatibility. Solaris 11 provides the priocntl command for process scheduling.

The priocntl switches are as follows:

Switch	Definition
-l	Lists the currently loaded scheduling tasks
-d	Displays the scheduling parameters of a process
-e	Creates a process by executing a command
-p	Changes the priority of an existing process
-c	Specifies the class in which the command executes

Firstly, display the currently loaded scheduling tasks:

root@solaris:~# priocntl -l
CONFIGURED CLASSES
==================
SYS (System Class)
TS (Time Sharing)
Configured TS User Priority Range: -60 through 60
SDC (System Duty-Cycle Class)
FX (Fixed priority)
Configured FX User Priority Range: 0 through 60
IA (Interactive)
Configured IA User Priority Range: -60 through 60
RT (Real Time)
Configured RT User Priority Range: 0 through 59

To display the scheduling parameters of the sleep process created earlier, use the following command replacing the PID value with the PID of your process:

root@solaris:~# priocntl -d -i pid 6790
INTERACTIVE CLASS PROCESSES:
PID[/LWP] IAUPRILIM IAUPRI IAMODE
6790 0 0 1

This output shows three columns:

Column	Description
IAUPRILIM	The inter-active per process user priority
IAUPRI	The inter-active user priority limit
IAMODE	The inter-active mode bit. When set, the process is given a priority boost of 10

To now modify the process priority ( nice value ) of your sleep command, use the following command and display the result:

root@solaris:~# priocntl -s -p -5 -i pid 6790
root@solaris:~# priocntl -d -i pid 6790
INTERACTIVE CLASS PROCESSES:
PID[/LWP] IAUPRILIM IAUPRI IAMODE
6790 0 -5 1

Note that a negative value reduces the global priority of the process. For more information concerning the use of this command, consult this page

The nohup Command

The nohup utility invokes the named command with the arguments supplied. When the command is invoked, nohup arranges for the SIGHUP signal to be ignored by the process. When invoked with the -p or -g switches, nohup arranges for processes already running as identified by a list of process IDs or a list of process group IDs to become immune to hang-ups.

root@solaris:~# nohup lp /root/sales &

proc tools

pcred

The pcred command shows the owner of a specified process:

root@solaris:~# pcred 1
1:	e/r/suid=0 e/r/sgid=0

pfiles

The pfiles command output diplays the open files associated with a process:

root@solaris:~# pfiles 1
1:	/usr/sbin/init
Current rlimit: 256 file descriptors
0: S_IFIFO mode:0600 dev:585,1 ino:4616249 uid:0 gid:0 size:0
O_RDWR|O_NDELAY
/system/volatile/initpipe
253: S_IFREG mode:0444 dev:583,1 ino:65538 uid:0 gid:0 size:0
O_RDONLY|O_LARGEFILE FD_CLOEXEC
/system/contract/process/pbundle
offset:0
254: S_IFREG mode:0666 dev:583,1 ino:65539 uid:0 gid:0 size:0
O_RDWR|O_LARGEFILE FD_CLOEXEC
/system/contract/process/template
offset:0
255: S_IFREG mode:0666 dev:583,1 ino:65539 uid:0 gid:0 size:0
O_RDWR|O_LARGEFILE FD_CLOEXEC
/system/contract/process/template
offset:0

pflags

The pflags command prints the /proc tracing flags, the pending and held signals and other /proc status information for the process:

root@solaris:~# pflags 1
1:	/usr/sbin/init
data model = _ILP32 flags = ORPHAN|MSACCT|MSFORK
/1:	flags = ASLEEP pollsys(0x806c040,0x1,0xf5d29688,0x0)

pldd

The pldd command lists the dynamic libraries linked into each process:

root@solaris:~# pldd 1 1: /usr/sbin/init /usr/lib/libc/libc_hwcap1.so.1 /lib/libcontract.so.1 /lib/libnvpair.so.1 /lib/libnsl.so.1 /lib/libscf.so.1 /lib/libuutil.so.1 /lib/libbsm.so.1 /lib/libtsol.so.2

pstack

The pstack command prints a hex+symbolic stack trace for each process:

root@solaris:~# pstack 1
1:	/usr/sbin/init
f4704ed7 pollsys (806c040, 1, f5d29688, 0)
f46aacc5 poll (806c040, 1, 493e0, 80545cf) + 81
080546b3 main (1, f5d2a00c, f5d2a014, f48278bc) + 427
080541ed _start (1, f5d2a088, 0, 0, 7d8, f5d2a097) + 7d

ptree

The ptree command prints a tree of all running processes showing their dependencies:

root@solaris:~# ptree
934 /usr/lib/fm/fmd/fmd
936 /usr/lib/ssh/sshd
957 /usr/sbin/syslogd
978 /usr/lib/sendmail -Ac -q15m
979 /usr/sbin/auditd
982 /usr/lib/sendmail -bl -q15m
1002 /usr/lib/vtdaemon -c 16
1106 /usr/lib/devchassis/devchassisd
1109 /usr/lib/inet/in.ndpd
1119 /usr/lib/rmvolmgr -s
1122 /usr/sbin/gdm-binary
1143 /usr/lib/gdm-simple-slave --display-id /org/gnome/DisplayManager/Display1
1159 /usr/bin/Xorg :0 -nolisten tcp -br -novtswitch -auth /tmp/gdm-auth-cookies-DOaq
1992 /usr/lib/gdm-session-worker
3579 gnome-session
3620 /usr/bin/ssh-agent -- gnome-session
3644 metacity
3645 gnome-panel
3648 nautilus
3653 /usr/lib/nwam-manager
3658 /usr/bin/python2.6 /usr/lib/updatemanagernotifier
3660 python2.6 /usr/lib/system-config-printer/applet.py
3661 java -Djava.security.policy=/usr/share/vpanels/java.policy com.oracle.solaris.v
3668 gnome-power-manager
3674 /usr/bin/xscreensaver -nosplash
3685 gnome-volume-control-applet
3688 python2.6 /usr/lib/time-slider-notify
1129 /usr/lib/fm/notify/asr-notify
1138 /usr/lib/fm/notify/smtp-notify
1406 /usr/sbin/cupsd -C /etc/cups/cupsd.conf
1456 /usr/bin/dbus-launch --exit-with-session
1495 /usr/apache2/2.2/bin/htcacheclean -d20160 -i -l 2048M -n -p /var/cache/pkg/sysr
1661 /usr/apache2/2.2/bin/64/httpd.worker -f /system/volatile/pkg/sysrepo/sysrepo_ht
1665 /usr/apache2/2.2/bin/64/httpd.worker -f /system/volatile/pkg/sysrepo/sysrepo_ht
1666 /usr/apache2/2.2/bin/64/httpd.worker -f /system/volatile/pkg/sysrepo/sysrepo_ht
1667 /usr/apache2/2.2/bin/64/httpd.worker -f /system/volatile/pkg/sysrepo/sysrepo_ht
1668 /usr/apache2/2.2/bin/64/httpd.worker -f /system/volatile/pkg/sysrepo/sysrepo_ht
1664 /usr/lib/zones/zoneproxyd
1822 zoneadmd -z myzone
2122 /usr/lib/ocm/ccr/bin/nmz
3608 dbus-launch --exit-with-session --sh-syntax
3609 /usr/lib/dbus-daemon --fork --print-pid 6 --print-address 8 --session
3633 /usr/lib/gconfd-2
3636 /usr/bin/gnome-keyring-daemon --start --components=pkcs11
3640 /usr/lib/gnome-settings-daemon
3643 /usr/lib/gvfsd
3647 /usr/lib/gvfs-hal-volume-monitor
3650 /usr/lib/bonobo-activation-server --ac-activate --ior-output-fd=21
3652 /usr/lib/wnck-applet --oaf-activate-iid=OAFIID:GNOME_Wncklet_Factory --oaf-ior-
3655 /usr/lib/trashapplet --oaf-activate-iid=OAFIID:GNOME_Panel_TrashApplet_Factory
3657 /usr/lib/gvfsd-trash --spawner :1.9 /org/gtk/gvfs/exec_spaw/0
3675 /usr/bin/VBoxClient --clipboard
3679 /usr/bin/VBoxClient --display
3682 /usr/bin/VBoxClient --seamless
3683 /usr/bin/VBoxClient --draganddrop
3698 /usr/lib/clock-applet --oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory --oaf
3700 /usr/lib/notification-area-applet --oaf-activate-iid=OAFIID:GNOME_NotificationA
3709 /usr/bin/pulseaudio --start
3720 /usr/lib/gvfsd-metadata
3722 /usr/lib/notification-daemon
3725 /usr/bin/firefox
3738 gnome-terminal
3739 gnome-pty-helper
3741 bash
3742 su -
3743 -bash
6891 sleep 9999
6932 ptree
3782 /usr/lib/gam_server
4985 zsched
5614 /usr/sbin/init
5770 /lib/svc/bin/svc.startd
6201 /usr/sbin/ttymon -g -d /dev/console -l console -T vt100 -m ldterm,ttcompat -h -
5774 /lib/svc/bin/svc.configd
5804 /lib/inet/netcfgd
5834 /lib/crypto/kcfd
5843 /usr/lib/pfexecd
5889 /usr/lib/utmpd
5893 /lib/inet/ipmgmtd
5906 /lib/inet/in.mpathd
5960 /lib/inet/nwamd
5968 /sbin/dhcpagent
6090 /usr/lib/zones/zoneproxy-client -s localhost:1008
6123 /usr/sbin/cron
6136 /usr/sbin/nscd
6165 /usr/sbin/rpcbind
6173 /usr/lib/autofs/automountd
6174 /usr/lib/autofs/automountd
6178 /usr/lib/inet/inetd start
6180 /usr/lib/fm/fmd/fmd
6181 /usr/lib/nfs/nfsmapid
6199 /usr/lib/ssh/sshd
6216 /usr/sbin/syslogd
6227 /usr/lib/sendmail -Ac -q15m
6236 /usr/lib/sendmail -bl -q15m
6242 /usr/lib/fm/notify/smtp-notify
6255 /usr/lib/inet/in.ndpd
11 /lib/svc/bin/svc.startd
985 /usr/sbin/ttymon -g -d /dev/console -l console -T sun-color -m ldterm,ttcompat
1012 /usr/sbin/ttymon -g -d /dev/vt/4 -l console -m ldterm,ttcompat -h -p solaris.fe
1013 /usr/sbin/ttymon -g -d /dev/vt/2 -l console -m ldterm,ttcompat -h -p solaris.fe
1014 /usr/sbin/ttymon -g -d /dev/vt/6 -l console -m ldterm,ttcompat -h -p solaris.fe
1015 /usr/sbin/ttymon -g -d /dev/vt/5 -l console -m ldterm,ttcompat -h -p solaris.fe
1016 /usr/sbin/ttymon -g -d /dev/vt/3 -l console -m ldterm,ttcompat -h -p solaris.fe
13 /lib/svc/bin/svc.configd
42 /lib/inet/netcfgd
50 /usr/sbin/dlmgmtd
85 /lib/crypto/kcfd
95 /lib/inet/ipmgmtd
104 /lib/inet/in.mpathd
118 /usr/lib/pfexecd
191 /usr/lib/utmpd
203 /usr/lib/zones/zonestatd
225 /usr/lib/sysevent/syseventd
235 /usr/sbin/vbiosd
237 /usr/lib/rad/rad -sp
3723 /usr/lib/rad/rad -m /usr/lib/rad/transport -m /usr/lib/rad/protocol -m /usr/lib
241 /usr/lib/dbus-daemon --system
413 /usr/lib/devfsadm/devfsadmd
570 /lib/inet/nwamd
637 /sbin/dhcpagent
679 /usr/lib/picl/picld
814 /usr/sbin/nscd
823 /lib/svc/method/iscsid
874 /usr/sbin/cron
881 /usr/sbin/rpcbind
890 /usr/lib/nfs/nfsmapid
891 /usr/lib/inet/inetd start
892 /usr/lib/hal/hald --daemon=yes
895 hald-runner
941 /usr/lib/hal/hald-addon-cpufreq
943 /usr/lib/hal/hald-addon-acpi
996 /usr/lib/hal/hald-addon-storage
896 /usr/sbin/console-kit-daemon
898 /usr/lib/autofs/automountd
899 /usr/lib/autofs/automountd
932 /usr/bin/VBoxService
6274 gedit
6736 nautilus --no-desktop /home/trainee

pwdx

The pwdx command prints the current working directory of a process:

root@solaris:~# pwdx 1 1: /

Process Scheduling

cron

The crond service, launched at boot time, is responsible for executing certain scripts and commands at specific intervals. The crond service assumes that the system is online permanently. In the case of a downtime coinciding with a cronjob, the cronjob is simply not executed until the following period.

In Solaris 11, every 60 seconds crond reads the system crontab files ( /var/spool/cron/crontabs/root, /var/spool/cron/crontabs/sys and /var/spool/cron/crontabs/adm ), any crontabs in /etc/cron.d/ and all the user crontabs:

root@solaris:~# cat /var/spool/cron/crontabs/root
#ident	"%Z%%M%	%I%	%E% SMI"
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# The root crontab should be used to perform accounting data collection.
#
#
10 3 * * * /usr/sbin/logadm
15 3 * * 0 [ -x /usr/lib/fs/nfs/nfsfind ] && /usr/lib/fs/nfs/nfsfind
30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean
30 0,9,12,18,21 * * * /usr/lib/update-manager/update-refresh.sh
root@solaris:~# cat /var/spool/cron/crontabs/sys
#ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.2	*/
#
# The sys crontab should be used to do performance collection. See cron
# and performance manual pages for details on startup.
#
# 0 * * * 0-6 /usr/lib/sa/sa1
# 20,40 8-17 * * 1-5 /usr/lib/sa/sa1
# 5 18 * * 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A
root@solaris:~# cat /var/spool/cron/crontabs/adm
#ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.2	*/
#
# The adm crontab file should contain startup of performance collection if
# the profiling and performance feature has been installed.
#

User crontabs are files named after the user who created them and can be found in /var/spool/cron/crontabs/:

root@solaris:~# ls /var/spool/cron/crontabs/
adm root sys

The crond service writes to the log file /var/cron/log:

root@solaris:~# cat /var/cron/log
! *** cron started *** pid = 1176 Tue Nov 20 19:27:50 2012
! SIGTERM Tue Nov 20 22:44:25 2012
! ******* CRON ABORTED ******** Tue Nov 20 22:44:25 2012
! *** cron started *** pid = 861 Tue Nov 20 22:46:22 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 3328 c Wed Nov 21 00:30:00 2012
< root 3328 c Wed Nov 21 00:34:25 2012
! *** cron started *** pid = 871 Sat Dec 1 14:33:18 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 3259 c Mon Dec 3 13:13:02 2012
! time was reset, re-initializing Mon Dec 3 13:13:02 2012
! SIGTERM Mon Dec 3 13:14:29 2012
! ******* CRON ABORTED ******** Mon Dec 3 13:14:29 2012
! *** cron started *** pid = 856 Mon Dec 3 13:16:23 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 4816 c Fri Dec 7 11:23:09 2012
! time was reset, re-initializing Fri Dec 7 11:23:09 2012
< root 4816 c Fri Dec 7 11:41:03 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 4858 c Fri Dec 7 13:26:23 2012
! time was reset, re-initializing Fri Dec 7 13:26:23 2012
< root 4858 c Fri Dec 7 13:26:23 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 7226 c Mon Dec 10 15:35:15 2012
! time was reset, re-initializing Mon Dec 10 15:35:15 2012
< root 7226 c Mon Dec 10 15:35:15 2012
! SIGTERM Tue Dec 11 12:13:34 2012
! ******* CRON ABORTED ******** Tue Dec 11 12:13:34 2012
! *** cron started *** pid = 7956 Tue Dec 11 12:16:49 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 7963 c Tue Dec 11 12:30:00 2012
< root 7963 c Tue Dec 11 12:30:00 2012
! SIGTERM Tue Dec 11 12:43:27 2012
! ******* CRON ABORTED ******** Tue Dec 11 12:43:27 2012
! *** cron started *** pid = 8011 Tue Dec 11 13:12:56 2012
! re-scheduling jobs Tue Dec 11 13:59:39 2012
! SIGTERM Tue Dec 11 15:01:00 2012
! ******* CRON ABORTED ******** Tue Dec 11 15:01:00 2012
! *** cron started *** pid = 9610 Tue Dec 11 15:02:25 2012
! SIGTERM Tue Dec 11 15:24:31 2012
! ******* CRON ABORTED ******** Tue Dec 11 15:24:31 2012
! *** cron started *** pid = 10892 Tue Dec 11 15:25:14 2012
! SIGTERM Tue Dec 11 15:32:51 2012
! ******* CRON ABORTED ******** Tue Dec 11 15:32:51 2012
! *** cron started *** pid = 865 Tue Dec 11 15:34:07 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 2646 c Wed Dec 12 08:46:52 2012
! time was reset, re-initializing Wed Dec 12 08:46:52 2012
! SIGTERM Wed Dec 12 08:47:05 2012
! ******* CRON ABORTED ******** Wed Dec 12 08:47:05 2012
! *** cron started *** pid = 854 Wed Dec 12 08:57:20 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 2375 c Wed Dec 12 09:30:00 2012
< root 2375 c Wed Dec 12 09:30:00 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 2511 c Wed Dec 12 13:33:08 2012
! time was reset, re-initializing Wed Dec 12 13:33:08 2012
< root 2511 c Wed Dec 12 13:33:08 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 3397 c Thu Dec 13 11:02:43 2012
! time was reset, re-initializing Thu Dec 13 11:02:43 2012
< root 3397 c Thu Dec 13 11:08:46 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 3487 c Thu Dec 13 12:58:15 2012
! time was reset, re-initializing Thu Dec 13 12:58:15 2012
< root 3487 c Thu Dec 13 12:58:15 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 4616 c Fri Dec 14 11:22:45 2012
! time was reset, re-initializing Fri Dec 14 11:22:45 2012
< root 4616 c Fri Dec 14 11:22:45 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 4633 c Fri Dec 14 12:30:19 2012
< root 4633 c Fri Dec 14 12:30:19 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 14029 c Sat Dec 15 06:21:22 2012
! time was reset, re-initializing Sat Dec 15 06:21:22 2012
! *** cron started *** pid = 874 Sat Dec 15 07:26:36 2012
! time was reset, re-initializing Sat Dec 15 06:26:41 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 6724 c Sat Dec 15 10:39:14 2012
! time was reset, re-initializing Sat Dec 15 10:39:14 2012
< root 6724 c Sat Dec 15 10:39:14 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 6795 c Mon Dec 17 15:47:04 2012
! time was reset, re-initializing Mon Dec 17 15:47:04 2012
< root 6795 c Mon Dec 17 15:47:05 2012
> CMD: /usr/lib/update-manager/update-refresh.sh
> root 6884 c Mon Dec 17 19:24:51 2012
! time was reset, re-initializing Mon Dec 17 19:24:51 2012
< root 6884 c Mon Dec 17 19:24:51 2012

If a command or script produces an output, that output is sent to root by mail.

The root user can establish lists of users that can or cannot create their own crontabs by editing either the /etc/cron.d/cron.allow or /etc/cron.d/cron.deny files:

root@solaris:~# ls /etc/cron.d
at.deny cron.deny queuedefs
root@solaris:~# cat /etc/cron.d/cron.deny
daemon
bin
nuucp

Each line in a crontab starts with five columns:

Minutes	Hours	Day of the month	Month	Day of the week
(0-59)	(0-23)	(1-31)	(1-12)	(0-6)*

* 0 is Sunday.

The following examples of values in those columns help explain how versatile a crontab can be:

Example	Description
An absolute value such as 10	In the Minutes column = 10 minutes after each hour
A series of values such as 2,6,8	In the Month column = February, June and August
A range such as 1-5	In the Day of the week column = From Monday through to Friday
The wildcard *	In the Day of the month column = Every day of the month
A regular interval such as 0-23/2	In the Hour column = Every two hours

The crond service can be configured by editing the /etc/default/cron file:

root@solaris:~# cat /etc/default/cron
#
# Copyright 1991 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#pragma ident	"%Z%%M%	%I%	%E% SMI"
CRONLOG=YES

In this file you can define variables such as PATH for normal users and SUPATH for the root role.

As already stated, each authorized user can create a crontab. To check if a crontab exists, the user needs to execute the following command:

trainee@solaris:~$ crontab -l
crontab: can't open your crontab file.

In order to create a crontab, the user should use the following command:

trainee@solaris:~$ crontab -e

at

As in the case of cron, root has the ability to control who can and cannot use the at command by editing one of the following:

/etc/cron.d/at.allow,

/etc/cron.d/at.deny.

If the at.allow file exists, only users in that file can use the at command.

Now take the example of root creating two at jobs for the 31/12 at 1pm and 2pm respectively:

root@solaris:~# at 13:00 Dec 31
at> pwd > /tmp/test1.atd
at> <EOT>
commands will be executed using /usr/bin/bash
job 1356955200.a at Mon Dec 31 13:00:00 2012
root@solaris:~#
root@solaris:~# at 14:00 Dec 31
at> free > /tmp/test2.atd
at> <EOT>
commands will be executed using /usr/bin/bash
job 1356958800.a at Mon Dec 31 14:00:00 2012

The at files created can be found in /var/spool/cron/atjobs/:

root@solaris:~# ls /var/spool/cron/atjobs/
1356955200.a 1356955200.a.au 1356958800.a 1356958800.a.au

Viewing the contents of the first file you will see something similar to the following example:

root@solaris:~# cat /var/spool/cron/atjobs/1356955200.a
: at job
: jobname: stdin
: notify by mail: no
: project: 1
export HZ; HZ=''
export SHELL; SHELL='/usr/bin/bash'
export TERM; TERM='xterm'
export PAGER; PAGER='/usr/bin/less -ins'
export MAIL; MAIL='/var/mail/root'
export PATH; PATH='/usr/bin:/usr/sbin'
export PWD; PWD='/root'
export LANG; LANG='en_US.UTF-8'
export SHLVL; SHLVL='1'
export HOME; HOME='/root'
export LOGNAME; LOGNAME='root'
export _; _='/usr/bin/at'
$SHELL << '...the rest of this file is shell input'
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.2	*/
cd /root
umask 22
pwd > /tmp/test1.atd

To delete that job you can use the at command with the following syntax:

root@solaris:~# at -l
user = root	1356958800.a	Mon Dec 31 14:00:00 2012
user = root	1356955200.a	Mon Dec 31 13:00:00 2012
root@solaris:~# at -r 1356958800.a
root@solaris:~# at -l
user = root	1356955200.a	Mon Dec 31 13:00:00 2012

To execute several commands at the same time, it is simple to create a text file containing the commands and then to redirect the contents of the file to at's standard input:

root@solaris:~# touch todo.list
root@solaris:~# echo pwd > todo.list
root@solaris:~# echo free >> todo.list
root@solaris:~# echo who >> todo.list
root@solaris:~# cat todo.list
pwd
free
who
root@solaris:~# at 14:30 Dec 31 < todo.list
commands will be executed using /usr/bin/bash
job 1356960600.a at Mon Dec 31 14:30:00 2012

<html> <div align=“center”> Copyright © 2019 Hugh Norris. </html>