solaris 11 exercise processes

Exercise Managing System Processes and Managing Tasks

1. Log in to your system and switch user to root.

user1@solaris11-1:~$ su -
Password:
Oracle Corporation SunOS 5.11 11.0 November 2011
You have new mail.
root@solaris11-1:~#

2. User the ps command to view your processes.

root@solaris11-1:~# ps
PID TTY TIME CMD
1435 pts/1 0:00 ps
1431 pts/1 0:00 bash
1430 pts/1 0:00 su
root@solaris11-1:~#

What is you shell?
Is the 'ps' command also running?

3. Use the ps command to display all processes one page at a time.

root@solaris11-1:~# ps -ef|more
UID PID PPID C STIME TTY TIME CMD
root 0 0 0 10:44:42 ? 0:01 sched
root 5 0 0 10:44:41 ? 0:13 zpool-rpool
root 6 0 0 10:44:43 ? 0:00 kmem_task
root 1 0 0 10:44:43 ? 0:00 /usr/sbin/init
root 2 0 0 10:44:43 ? 0:00 pageout
root 3 0 0 10:44:43 ? 0:00 fsflush
root 7 0 0 10:44:43 ? 0:00 intrd
(snipped)

4. What does the prstat command do?

root@solaris11-1:~# prstat
prstat: failed to load terminal info, defaulting to -c option
Please wait...
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
939 root 38M 7596K run 59 0 0:00:00 0.2% pkg.depotd/64
1213 gdm 136M 27M sleep 59 0 0:00:00 0.1% gdm-simple-gree/1
1438 root 11M 3140K cpu0 59 0 0:00:00 0.1% prstat/1
911 root 31M 23M sleep 59 0 0:00:01 0.0% Xorg/3
1431 root 10M 2380K sleep 49 0 0:00:00 0.0% bash/1
1423 user1 18M 5704K run 59 0 0:00:00 0.0% sshd/1
45 netcfg 3784K 2764K sleep 59 0 0:00:00 0.0% netcfgd/4
129 root 13M 2796K sleep 59 0 0:00:00 0.0% syseventd/18
461 root 8860K 1180K sleep 59 0 0:00:00 0.0% cron/1
70 daemon 14M 4624K sleep 59 0 0:00:00 0.0% kcfd/3
1116 gdm 3768K 1396K sleep 59 0 0:00:00 0.0% dbus-launch/1
46 root 3868K 2560K sleep 59 0 0:00:00 0.0% dlmgmtd/6
118 root 2124K 1176K sleep 59 0 0:00:00 0.0% pfexecd/3
13 root 21M 20M sleep 59 0 0:00:12 0.0% svc.configd/47
11 root 21M 12M sleep 59 0 0:00:03 0.0% svc.startd/12
Total: 101 processes, 935 lwps, load averages: 0.05, 0.41, 0.25

PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP

5. Use prstat to view the highest CPU usage every 5 seconds 10 times.

root@solaris11-1:~# prstat -s cpu 5 10
prstat: failed to load terminal info, defaulting to -c option
Please wait...
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
939 root 38M 7596K sleep 59 0 0:00:00 0.2% pkg.depotd/64
1213 gdm 136M 27M sleep 59 0 0:00:00 0.1% gdm-simple-gree/1
911 root 31M 23M sleep 59 0 0:00:01 0.0% Xorg/3
1441 root 11M 3040K cpu0 59 0 0:00:00 0.0% prstat/1
(snipped)

6. What is the difference between -s and -S in the following command?

root@solaris11-1:~# prstat -S rss 2 2
prstat: failed to load terminal info, defaulting to -c option
Please wait...
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
697 root 0K 0K sleep 60 - 0:00:00 0.0% nfsd_kproc/2
542 root 0K 0K sleep 60 - 0:00:00 0.0% lockd_kproc/2
229 root 0K 0K sleep 99 -20 0:00:00 0.0% zpool-p1/136
248 root 0K 0K sleep 99 -20 0:00:00 0.0% zpool-software/136
533 root 0K 0K sleep 60 - 0:00:00 0.0% nfs4cbd_kproc/2
181 root 0K 0K sleep 99 -20 0:00:00 0.0% zpool-kanweg/136

root@solaris11-1:~# prstat -s rss 2 2
prstat: failed to load terminal info, defaulting to -c option
Please wait...
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
1206 gdm 141M 31M sleep 59 0 0:00:00 0.0% gnome-settings-/1
1213 gdm 136M 27M sleep 59 0 0:00:01 0.1% gdm-simple-gree/1
911 root 31M 23M sleep 59 0 0:00:01 0.0% Xorg/3
13 root 21M 20M sleep 59 0 0:00:12 0.0% svc.configd/47
1212 gdm 129M 18M sleep 59 0 0:00:00 0.0% gnome-power-man/1

7. Check whether sendmail is running.

root@solaris11-1:~# pgrep -l sendmail
1416 sendmail
1418 sendmail

8. Kill sendmail.

root@solaris11-1:~# pkill sendmail
root@solaris11-1:~# pgrep -l sendmail
1464 sendmail
1460 sendmail
root@solaris11-1:~#

9. Start a program in the background that runs for 10000 seconds.

root@solaris11-1:~# sleep 10000 &
[1] 1471

10. Stop the sleep program, and start it again.

root@solaris11-1:~# kill -STOP %1
root@solaris11-1:~# jobs
[1]+ Stopped sleep 10000
root@solaris11-1:~# bg %1
[1]+ sleep 10000 &
root@solaris11-1:~#

9. List your scheduled tasks.

root@solaris11-1:~# crontab -l
#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@solaris11-1:~#

10. Create a script that sleeps for 30 seconds and add it to your tasks. The
script should run every minute.

root@solaris11-1:~# echo "/usr/bin/sleep 30&" > /usr/bin/sleeper
root@solaris11-1:~# chmod +x /usr/bin/sleeper
#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
* * * * * /usr/bin/sleeper
:wq!

Check whether the taks gets started.
root@solaris11-1:~# pgrep -lf sleep
1513 /usr/bin/sleep 30

11. Confure cron.deny so that user1 (or any other user) is not allowed
to use cron, and test it.

root@solaris11-1:~# echo "user1" >> /etc/cron.d/cron.deny
root@solaris11-1:~# su - user1
Oracle Corporation SunOS 5.11 11.0 November 2011
user1@solaris11-1:~$ crontab -e
crontab: you are not authorized to use cron. Sorry.
user1@solaris11-1:~$exit

12. Where are the cron-files stored?

root@solaris11-1:~# ls /var/spool/cron/crontabs
adm root root.au sys

This entry was posted in solaris. Bookmark the permalink.

Comments are closed.