Chapter 5. Job Control

   

Korn Shell: Unix and Linux Programming Manual, Third Edition, The
By Anatole Olczak

Table of Contents


Manipulating Jobs

Checking Job Status

Background Jobs and I/O

Job Names

Leaving Stopped Jobs

The Korn shell provides a job control mechanism that is virtually identical to the C shell version of BSD Unix. Job control allows programs to be stopped and restarted, moved between the foreground and background, their processing status to be displayed, and more. To enable the job control feature, the monitor option must be enabled with the set command:

 $ set  o monitor 

or

 $ set  m 

This can be put into the .profile file so that job control is automatically enabled at login. On most systems that provide the job control mechanism, this option is automatically enabled for interactive shells.

It can be checked by executing the set o command. Let's see if it is set:

 $ set  o | grep monitor  monitor            on 

If a command is run in the background, the Korn shell returns a job number and process id. Here, the find command is assigned job number 1 and process id 1435:

 $ find /  name core  exec rm  rf {} \; &  [1] 1435 

The next command is assigned job number 2 and process id 1437:

 $ cpio  iBcdu < /dev/rmt0 &  [2] 1437 

When background jobs are completed, a message is given before the next prompt is displayed. This is done so that other work is not interfered with. In this example, the ls command is put in the background. Although it finished before the sleep command, the completion message is not displayed until sleep is finished:

 $ ls  x > ls.out &  [3] 1438  $ sleep 30  [3] + Done          ls  x > ls.out &  $ 

       
    Top
     



    Korn Shell. Unix and Linux Programming Manual, Third Edition
    Korn Shell. Unix and Linux Programming Manual, Third Edition
    ISBN: N/A
    EAN: N/A
    Year: 2000
    Pages: 177

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net