Information Technology Reference
In-Depth Information
The other command-line argument is
-l
, which includes the name of the
program with the PIDs of matched processes. The following listing shows
the use of the
-l
command-line argument:
$ pgrep -l -u ambro
781 xterm
782 sh
910 telnet
913 sh
$
The
pkill
command is similar to the
pgrep
command, but instead of dis-
playing information on matched processes, the matched processes are termi-
nated using the
SIGTERM (15)
signal.
All the common
pgrep
and
pkill
command-line arguments listed in Table
5.4 are supported, allowing processes to be selected on the basis of regular
expression pattern matching and/or various IDs. In addition, the
pkill
command supports a command-line argument to specify a signal to be used
instead of
SIGTERM
. This command-line argument is the minus sign followed
by a symbolic name (not including the SIG prefix) or the signal number. The
following listing shows the use of the
SIGKILL
signal to terminate all process-
es associated with the
ambro
user account:
# pkill -KILL -u ambro
#
Be familiar with the signals used to terminate processes. Know how to specify using
both signal numbers and names along with the default signals used by the
kill
and
pkill
commands.
Scheduling Processes
Two commands are available for scheduling automatic execution of processes:
cron(1M)
and
at(1)
.
The cron Command
The
cron
command is a daemon started during system boot. It is responsible
for executing commands at a future time and perhaps periodically on a
scheduled basis. The commands to be executed are specified in a standard-
ized tabular format and stored in files referred to as
crontab
files
. These files
are located in the
/var/spool/cron/crontabs
directory.