Summary
This chapter described Solaris processes and the various Solaris utilities available to monitor them. Using commands such as ps, prstat, pargs, sdtprocess, and the SMC Process Tool, you can view all the attributes associated with a process. In addition, we described foreground and background jobs.
The concept of sending signals to a process was described. A signal is a message sent to a process to interrupt it and cause a response or action. You also learned how to send signals to processes to cause a response such as terminating a process.
Setting process priorities was described. We also described the concept of projects and tasks along with administrative commands used to administer them. The various commands, such as nice and priocntl, that are used to set and change process priorities were described. In addition, you learned how to use the crontab and at facilities. You can use these facilities to submit batch jobs and schedule processes to run when the system is less busy, to reduce the demand on resources such as the CPU and disks.
The system administrator needs to be aware of the processes that belong to each application. As users report problems, the system administrator can quickly locate the processes being used and look for irregularities. By keeping a close watch on system messages and processes, you'll become familiar with what is normal and what is abnormal. Don't wait for problems to happen—watch system messages and processes daily. Create shell scripts to watch processes for you and to look for irregularities in the system log files. By taking a proactive approach to system administration, you'll find problems before they affect the users.
In Chapter 6, "Managing the LP Print Service," we'll explore another topic that you'll need to become acquainted with—the LP Print Service, the facility responsible for printing within the Solaris environment.
Key Terms
- at command
- Process Manager GUI
- Child process
- cron
- crontab
- crontab file
- mpstat
- ptree
- nice command
- Parent process
- pgrep command
- preap command
- priocntl command
- Process
- Project (as it relates to process management)
- prstat command
- ps command
- Signals
- SMC Job Scheduler
- SMC Process Tool
- time
- Zombie process
Exercises
5.1 Displaying Process Information
In this exercise, you'll use the various utilities described in this chapter to display information about active processes.
Estimated time: 10 minutes
- Log in as root into the Java Desktop Environment or CDE.
Open a new window and display the active processes using the ps command:
# ps -ef
Open another new window and display the active processes using the prstat command:
# prstat
Notice how the ps command took a snapshot of the active processes, but the prstat command continues to update its display.
- Type q to exit prstat.
Display the dtlogin process and all of its child processes. First obtain the PID of the dtlogin process with the pgrep command:
# pgrep dtlogin
Now use the ptree command with the PID of the dtlogin process to display the ancestry tree:
# ptree <PID from dtlogin>
Now start the Process Manager.
# sdtprocess &
Notice how the window updates periodically.
- In the sample field at the top of the window, change the sample period from 30 to 5 seconds.
- Sort the processes by ID by clicking on the ID button in the header.
5.2 Using the Batch Process
In this exercise, you'll use crontab to configure a process to execute everyday at a specified time.
Estimated time: 10 minutes
- Log in as root into a Java Desktop or CDE session.
- Make sure your default shell editor is set to vi (EDITOR=vi;export EDITOR) before beginning this exercise.
Open a new window and edit the crontab entry.
# crontab -e
Enter the following after the last line at the end of the file:
0 11 * * * echo Hand in Timesheet > /dev/console
Save and close the file.
Open a console window and at 11:00 a.m., you'll see the message Hand in Timesheet displayed.
Exam Questions
- Which of the following commands finds all processes that have dt in the process argument string? Choose all that apply.
A.
pgrep -l -f dt
B.
ps -ef dt
C.
ps -el dt
D.
ps -ef|grep dt
- Which one of the following commands kills a process named test?
A.
pkill test
B.
kill test
C.
ps -ef||grep kill| kill -9
D.
kill -test
- Which commands display active system processes and update at a specified interval? Choose all that apply.
A.
ps
B.
prstat
C.
sdtprocess
D.
ptree
- In output from the ps command, what does an R stand for in the S field?
A.
The process is on the run queue.
B.
The process is receiving input.
C.
It is a regular process.
D.
The process is sleeping, so it must be restarted.
- In output from the ps command, which of the following does the UID field display?
A.
The parent process
B.
The process id
C.
The process owner
D.
The priority of the process
- Which one of the following options to the ps command lists only processes for a particular user?
A.
-P
B.
-f
C.
-l
D.
-u
- Which one of the following commands lists all processes running on the local system?
A.
ps -e
B.
ps -a
C.
ps -f
D.
ps -t
- Which one of the following sends a terminate signal (signal 15) to a process with a PID of 2930?
A.
kill 2930
B.
stop 2930
C.
Ctrl+C
D.
cancel 2930
- Which one of the following signals kills a process unconditionally?
A.
9
B.
0
C.
15
D.
1
- Which of the following commands is used to change the priority on a process? Choose all that apply.
A.
renice
B.
priocntl
C.
ps
D.
hup
- Which one of the following commands is issued to increase the priority of PID 8200?
A.
renice -n -4 -p 8200
B.
nice -n -4 -p 8200
C.
nice -i 8200
D.
renice -I -p 8200
- Which utilities can be used to show the process ancestry tree? Choose all that apply.
A.
ps
B.
ptree
C.
sdtprocess
D.
prstat
- Which of the following commands schedules a command to run once at a given time?
A.
crontab
B.
priocntl
C.
at
D.
cron
- Which of the following commands show(s) the jobs queued up by the at command? Choose all that apply.
A.
atq
B.
at -l
C.
ps
D.
crontab
- Which one of the following crontab entries instructs the system to run logchecker at 3:10 on Sunday and Thursday nights?
A.
0 4 * * 10,3 /etc/cron.d/logchecker
B.
10 3 * * 0,4 /etc/cron.d/logchecker
C.
* 10 3 0,4 /etc/cron.d/logchecker
D.
10 3 * * 0-4 /etc/cron.d/logchecker
- Which one of the following logs keeps a record of all cron activity?
A.
/var/cron/log
B.
/var/spool/cron/log
C.
/var/adm/cron
D.
/var/adm/messages
- A user wants to execute a command later today, after leaving work. Which one of the following commands will allow him to do this?
A.
runat
B.
at
C.
submit
D.
None of the above
- You've added the user name bcalkins to the /etc/cron.d/cron.allow file. You've removed the name bcalkins from the /etc/cron.d/cron.deny file. Which statement is true regarding crontab?
A.
bcalkins cannot create crontab entries.
B.
bcalkins can create crontab entries.
C.
Only root can create crontab entries.
D.
No one can create crontab entries.
Answers to Exam Questions
- A, D. Use the pgrep and ps commands to view processes running on your system. The commands pgrep -l -f dt and ps -ef|grep dt find all the processes that have dt in the process argument string and display them.
- A. The command pkill test kills a process named test.
- B, C. The prstat and sdtprocess commands display active system processes and can be configured to update at a specified interval.
- A. In output from the ps command, the R in the S field means that the process is on the run queue.
- C. In output from the ps command, the UID field displays the process owner.
- D. The -u option to the ps command lists only processes for a particular user.
- A. The -e option to the ps command lists all processes currently running on the system. The other options only list processes for the local user.
- A. The command kill 2930 sends a terminate signal (signal 15) to a process with a PID of 2930.
- A. Signal 9 stops a process unconditionally.
- A, B. The commands renice and priocntl are used to change the priority on a process.
- A. The renice -n -4 -p 8200 command is issued to increase the priority of a process with a PID of 8200.
- B, C. The utilities ptree and sdtprocess are used to show the process ancestry tree.
- C. The at command schedules a command to run once at a given time.
- A, B. The atq and at -1 commands show the jobs queued up by the at command.
- B. The crontab entry 10 3 * * 0,4 /etc/cron.d/logchecker instructs the system to run logchecker at 3:10 on Sunday and Thursday nights.
- A. The log file named /var/cron/log keeps a record of all cron activity.
- B. Use the at command to execute a command or script at a later time.
- B. Users can manage jobs if their name appears in the /etc/cron.d/cron.allow file and does not appear in the /etc/cron.d/cron.deny file.