Linux Job Management Notes: Difference between revisions

From ITCwiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 12: Line 12:


If a job is already running and has control of the terminal you can press CTRL+Z in the terminal window, the job will stop, give control back to bash, and you will receive a command line.  
If a job is already running and has control of the terminal you can press CTRL+Z in the terminal window, the job will stop, give control back to bash, and you will receive a command line.  
When you bring a job that was running in the background to the foreground using the fg command you give control of the terminal back to that job. To bring a job to the foreground use this command:
When you bring a job that was running in the background to the foreground using the fg command you give control of the terminal back to that job. To bring a job to the foreground use this command:


Line 33: Line 31:
'''Example''': at the command line type ps auxww | less you can then use the down arrow to scroll line by line.  
'''Example''': at the command line type ps auxww | less you can then use the down arrow to scroll line by line.  


The top command shows what is running on your system in real time it refreshes every two to three seconds. Top is an interactive program with a command line within the program that can be used to prioritize or kill processes to start the top program use the following command.  
The top command shows what is running on your system in real time it refreshes every two to three seconds. Top is an interactive program with a command line within the program that can be used to prioritize or kill processes.
To start the top program use the following command.  


'''Example''': at the command line type top press Enter
'''Example''': at the command line type top press Enter

Revision as of 03:57, 14 July 2011

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

The user login shell is the first program that runs when you log into the workstation. The formal definition for this 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. You can 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.

You can start a job using the ampersand & this states a condition that the job give up control of the terminal 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 you can press CTRL+Z in the terminal window, the job will stop, give control back to bash, and you will receive a command line. When you bring a job that was running in the background to the foreground using the fg command you give control of the terminal back 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 back 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 ps auxww

Example: at the command line type ps auxww press Enter

It you want to look at the processes that are running on your system line by line you can use | less like this. Example: at the command line type ps auxww | less you can then use the down arrow to scroll line by line.

The top command shows what is running on your system in real time it refreshes every two to three seconds. Top is an interactive program with a command line within the program that can be used to prioritize or kill processes. To start the top program use the following command.

Example: at the command line type top press Enter