Main index

Introducing UNIX and Linux


Processes and devices

Overview
Processes
      Process status
      Foreground and background
      Process control
      Signals
Environment
      Environment variables
      Global and local variables
      Executable scripts
Program control
      Job control
      Command history list
      Running a job at a specific time
      Running programs periodically
      Big programs
      Timing a program
      Running programs in order
Quotes and escapes
Devices
Backquotes
Summary
Exercises

Process control

To illustrate how we can control processes, we use as an example the command sleep. Followed by an integer, sleep suspends execution of the current shell for that number of seconds, so:

date
Fri Dec 7 17:22:21 GMT 2001
sleep 15

(there is a delay of 15 seconds at this point)
date
Fri Dec 7 17:22:36 GMT 2001

So sleep is a command that essentially does nothing, but a process is created for it nonetheless. So we might have:

sleep 100 &
[1] 16403
ps
  PID TTY      TIME COMMAND
10312 p7   00:02:25 sh
16403 p7   00:00:00 sleep 100
16425 p7   00:00:00 ps

After 100 seconds process number 16403 will terminate. The system confirms that the command has been sent to run in the background by printing a line containing jobnumber (enclosed in square brackets), and the process ID number (16403) of the command. Jobs are discussed later on in this chapter.


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck