Previous Page
Next Page

Key Terms

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.

  1. pgrep -l -f dt

  1. ps -ef dt

  1. ps -el dt

  1. ps -ef|grep dt


2.

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

  1. pkill test

  1. kill test

  1. ps -ef||grep kill| kill -9

  1. kill test


3.

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

  1. ps

  1. prstat

  1. sdtprocess

  1. ptree


4.

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

  1. The process is on the run queue.

  1. The process is receiving input.

  1. It is a regular process.

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

  1. The parent process

  1. The process id

  1. The process owner

  1. The priority of the process


6.

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

  1. -P

  1. -f

  1. -l

  1. -u


7.

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

  1. ps -e

  1. ps -a

  1. ps -f

  1. ps -t


8.

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

  1. kill 2930

  1. stop 2930

  1. Ctrl+C

  1. cancel 2930


9.

Which one of the following signals kills a process unconditionally?

  1. 9

  1. 0

  1. 15

  1. 1


10.

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

  1. renice

  1. priocntl

  1. ps

  1. hup


11.

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

  1. renice -n -4 -p 8200

  1. nice -n -4 -p 8200

  1. nice -i 8200

  1. renice -I -p 8200


12.

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

  1. ps

  1. ptree

  1. sdtprocess

  1. prstat


13.

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

  1. crontab

  1. priocntl

  1. at

  1. cron


14.

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

  1. atq

  1. at -1

  1. ps

  1. crontab


15.

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

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

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

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

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


16.

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

  1. /var/cron/log

  1. /var/spool/cron/log

  1. /var/adm/cron

  1. /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?

  1. runat

  1. at

  1. submit

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

  1. bcalkins cannot create crontab enTRies.

  1. bcalkins can create crontab enTRies.

  1. Only root can create crontab entries.

  1. 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.


Previous Page
Next Page