The jobs command, Canceling a foreground process (ctrl-c), Canceling a background process (kill) – HP NonStop G-Series User Manual

Page 141

Advertising
background image

57618 #ptmy11a 00:00 /bin/-sh

46150 #ptmykzh 00:00 vi

57570 #ptmy110 00:00 <defunct>

85419 #ptmy110 00:00 <defunct>

Generally, the simple ps command described here tells you what you need to know about processes.
However, you can control the type of information that the ps command displays by using more of
its flags. One of the most useful ps flags is -e, which causes ps to return information about all
processes, not just those associated with your workstation. For an explanation of all ps command
flags, see the ps(1) reference page either online or in the Open System Services Shell and Utilities
Reference Manual
.

The jobs Command

The jobs command displays the status of all background processes associated with your
workstation, based upon the job number.

The jobs command has the following form:

jobs

Adding the -l flag displays both the job number and the process ID.

Canceling a Foreground Process (Ctrl-c)

To cancel a foreground process (that is, to stop an executing command), press Ctrl-c. The process
stops executing and the system displays the shell prompt. Note that canceling a command is the
same as stopping the execution of a foreground process.

A command that takes a long time to execute must be used to demonstrate how to cancel a
foreground process. (Most commands finish executing before a cancel command can be issued.)
The following find command runs long enough for you to cancel it by pressing Ctrl-c:

$ find / -type f -print

/usr/sbin/acct/acctcms
/usr/sbin/acct/acctcon1
/usr/sbin/acct/acctcon2
/usr/sbin/acct/acctdisk
/usr/sbin/acct/acctmerg
/usr/sbin/acct/accton
/usr/sbin/acct/acctprc1
/usr/sbin/acct/acctprc2
/usr/sbin/acct/acctwtmp
/usr/sbin/acct/chargefee
/usr/sbin/acct/ckpacct
/usr/sbin/acct/dodisk

<Ctrl-c>

$

The system returns the shell prompt to the screen, then you can enter another command.

Canceling a Background Process (kill)

If, after starting a background process, you decide that you do not want the process to finish, you
can cancel it with the kill command. Before you can cancel a background process, however,
you must know its process ID.

If you have forgotten the process ID of a process, use the ps command to list the process IDs of
both foreground and background processes, or use the jobs command to list the process IDs of
just background processes.

Monitoring and Canceling Processes

141

Advertising
This manual is related to the following products: