Home > Articles > Certification > Other IT

  • Print
  • + Share This
This chapter is from the book

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

  1. Log in as root into the Java Desktop Environment or CDE.
  2. Open a new window and display the active processes using the ps command:

    # ps -ef
  3. 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.

  4. Type q to exit prstat.
  5. 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>
  6. Now start the Process Manager.

    # sdtprocess &

    Notice how the window updates periodically.

  7. In the sample field at the top of the window, change the sample period from 30 to 5 seconds.
  8. 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

  1. Log in as root into a Java Desktop or CDE session.
  2. Make sure your default shell editor is set to vi (EDITOR=vi;export EDITOR) before beginning this exercise.
  3. Open a new window and edit the crontab entry.

    # crontab -e
  4. Enter the following after the last line at the end of the file:

    0 11 * * * echo Hand in Timesheet > /dev/console
  5. 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

  1. Which of the following commands finds all processes that have dt in the process argument string? Choose all that apply.

    circle.gif

    A.

    pgrep -l -f dt

    circle.gif

    B.

    ps -ef dt

    circle.gif

    C.

    ps -el dt

    circle.gif

    D.

    ps -ef|grep dt

  2. Which one of the following commands kills a process named test?

    circle.gif

    A.

    pkill test

    circle.gif

    B.

    kill test

    circle.gif

    C.

    ps -ef||grep kill| kill -9

    circle.gif

    D.

    kill -test

  3. Which commands display active system processes and update at a specified interval? Choose all that apply.

    circle.gif

    A.

    ps

    circle.gif

    B.

    prstat

    circle.gif

    C.

    sdtprocess

    circle.gif

    D.

    ptree

  4. In output from the ps command, what does an R stand for in the S field?

    circle.gif

    A.

    The process is on the run queue.

    circle.gif

    B.

    The process is receiving input.

    circle.gif

    C.

    It is a regular process.

    circle.gif

    D.

    The process is sleeping, so it must be restarted.

  5. In output from the ps command, which of the following does the UID field display?

    circle.gif

    A.

    The parent process

    circle.gif

    B.

    The process id

    circle.gif

    C.

    The process owner

    circle.gif

    D.

    The priority of the process

  6. Which one of the following options to the ps command lists only processes for a particular user?

    circle.gif

    A.

    -P

    circle.gif

    B.

    -f

    circle.gif

    C.

    -l

    circle.gif

    D.

    -u

  7. Which one of the following commands lists all processes running on the local system?

    circle.gif

    A.

    ps -e

    circle.gif

    B.

    ps -a

    circle.gif

    C.

    ps -f

    circle.gif

    D.

    ps -t

  8. Which one of the following sends a terminate signal (signal 15) to a process with a PID of 2930?

    circle.gif

    A.

    kill 2930

    circle.gif

    B.

    stop 2930

    circle.gif

    C.

    Ctrl+C

    circle.gif

    D.

    cancel 2930

  9. Which one of the following signals kills a process unconditionally?

    circle.gif

    A.

    9

    circle.gif

    B.

    0

    circle.gif

    C.

    15

    circle.gif

    D.

    1

  10. Which of the following commands is used to change the priority on a process? Choose all that apply.

    circle.gif

    A.

    renice

    circle.gif

    B.

    priocntl

    circle.gif

    C.

    ps

    circle.gif

    D.

    hup

  11. Which one of the following commands is issued to increase the priority of PID 8200?

    circle.gif

    A.

    renice -n -4 -p 8200

    circle.gif

    B.

    nice -n -4 -p 8200

    circle.gif

    C.

    nice -i 8200

    circle.gif

    D.

    renice -I -p 8200

  12. Which utilities can be used to show the process ancestry tree? Choose all that apply.

    circle.gif

    A.

    ps

    circle.gif

    B.

    ptree

    circle.gif

    C.

    sdtprocess

    circle.gif

    D.

    prstat

  13. Which of the following commands schedules a command to run once at a given time?

    circle.gif

    A.

    crontab

    circle.gif

    B.

    priocntl

    circle.gif

    C.

    at

    circle.gif

    D.

    cron

  14. Which of the following commands show(s) the jobs queued up by the at command? Choose all that apply.

    circle.gif

    A.

    atq

    circle.gif

    B.

    at -l

    circle.gif

    C.

    ps

    circle.gif

    D.

    crontab

  15. Which one of the following crontab entries instructs the system to run logchecker at 3:10 on Sunday and Thursday nights?

    circle.gif

    A.

    0 4 * * 10,3 /etc/cron.d/logchecker

    circle.gif

    B.

    10 3 * * 0,4 /etc/cron.d/logchecker

    circle.gif

    C.

    * 10 3 0,4 /etc/cron.d/logchecker

    circle.gif

    D.

    10 3 * * 0-4 /etc/cron.d/logchecker

  16. Which one of the following logs keeps a record of all cron activity?

    circle.gif

    A.

    /var/cron/log

    circle.gif

    B.

    /var/spool/cron/log

    circle.gif

    C.

    /var/adm/cron

    circle.gif

    D.

    /var/adm/messages

  17. A user wants to execute a command later today, after leaving work. Which one of the following commands will allow him to do this?

    circle.gif

    A.

    runat

    circle.gif

    B.

    at

    circle.gif

    C.

    submit

    circle.gif

    D.

    None of the above

  18. 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?

    circle.gif

    A.

    bcalkins cannot create crontab entries.

    circle.gif

    B.

    bcalkins can create crontab entries.

    circle.gif

    C.

    Only root can create crontab entries.

    circle.gif

    D.

    No one can create crontab entries.

Answers to Exam Questions

  1. 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.
  2. A. The command pkill test kills a process named test.
  3. B, C. The prstat and sdtprocess commands display active system processes and can be configured to update at a specified interval.
  4. A. In output from the ps command, the R in the S field means that the process is on the run queue.
  5. C. In output from the ps command, the UID field displays the process owner.
  6. D. The -u option to the ps command lists only processes for a particular user.
  7. 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.
  8. A. The command kill 2930 sends a terminate signal (signal 15) to a process with a PID of 2930.
  9. A. Signal 9 stops a process unconditionally.
  10. A, B. The commands renice and priocntl are used to change the priority on a process.
  11. A. The renice -n -4 -p 8200 command is issued to increase the priority of a process with a PID of 8200.
  12. B, C. The utilities ptree and sdtprocess are used to show the process ancestry tree.
  13. C. The at command schedules a command to run once at a given time.
  14. A, B. The atq and at -1 commands show the jobs queued up by the at command.
  15. 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.
  16. A. The log file named /var/cron/log keeps a record of all cron activity.
  17. B. Use the at command to execute a command or script at a later time.
  18. 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.
  • + Share This
  • 🔖 Save To Your Account