Open Directory Site  Advanced Unix Tutorials

Home | Windows 98 | Windows Me | Windows 2000 Windows XP | Unix | Advanced Unix

Home >> Operating Systems >> Advanced Unix >> Job Control

Job Control

UNIX is a multi-tasking operating system that allows multiple jobs to be running concurrently. There are features of UNIX that let you control these jobs from commands entered at the shell prompt or from the console.

First, a job is any application that you begin as a command from a shell prompt. Normally when you execute an application, you continue to work with that program in this shell until it completes. Some programs run so quickly that you just wait momentarily for them to finish executing. Some commands, however, may take a long time to complete. These include compiling, database searches, file retrieval via ftp, and so on. While these jobs are running, you would probably like to do something else with the machine, for instance read mail or edit a file.

 

There are a couple ways to place jobs in the background. The first, which is the easiest, is to append an ampersand (&) to the end of the command. This puts the job in the background upon execution and the shell prompt returns immediately. Another way is to type Ctrl-z while the job is running in the foreground. This suspends execution of the job. Then you can type in the command bg. That will put the most recently stopped job in the background. If you are interested in killing the job altogether while it is in the foreground, type Ctrl-c.

 

The jobs command will show a list of all of your jobs that are currently running in the background along with their job number. If you wish to observe and interact with a job, you can put it into the foreground by typing fg job_number. To stop, or suspend, a job from the job list, type stop job_number,. To kill one of your jobs, type kill job_number.

 

Other useful job control commands that are worth looking into are ps, babysit, nohup, and nice. For more information on job control, consult the CAEN Technote: Running Remote Jobs.

Cheap Web Hosting Articles - Web Site Design & Web Hosting Tutorials - Domain Hosting