Linux Job Management Notes

From ITCwiki
Revision as of 03:11, 13 July 2011 by Shari (talk | contribs)
Jump to navigation Jump to search

Job management and control: &, CTRL-Z, jobs, fg, bg

The user login shell is the first program that runs when the user logs into the workstation. The formal definition of the program is a command language interpreter that executes commands; also referred to as an interface between the user and the system. Bash (Bourne Again Shell) is a command line-only interface where programs also referred to as jobs are lunched and controlled, when a job starts it takes control of the terminal, when the job is finished, control is given back to bash, and a command line is redisplayed for the user. However, you can start a job using the ampersand & that states a condition that the job give up control to bash, and give the user a command line while the job continues to run in the background.

Example: At the command line type program name & press Enter, the job continues to run in the background and you receive a command line and can continue working.

If a job is already running and has control of the terminal pressing CTRL-Z in the terminal window, will stop the job, give control back to bash, and you will receive a command line. You can also see a list of jobs that bash is tracking; along with their status, by using the jobs command.

Example: At the command line type jobs press Enter, the following information is displayed [Job number] Status of program, running or stopped Program name & after program name if used.

When you bring a job that was running in the background to the foreground using the fg command you also give back control of the terminal to that job. To bring a job to the foreground use this command:

Example: at the command line type fg job number from the jobs list

You can send a running job to the background using the bg command as follows:

Example: at the command line type bg job number from the ps jobs list.

To start a job stopped in the background bring it to the foreground using fg, then if you want, you can send it back to the background using bg it will continue running in the background.

Processes: ps, top, kill signal

The ps command stands for process status it list all the processes in a system, if they are running, stopped, or in a zombie state. The most common parameter is auxww Example: at the command line type ps auxww press Enter