Processes and Job Control. Foreground and Background (1)  Unix is a multi-tasking operating system –some of these tasks are being done by other users.

Slides:



Advertisements
Similar presentations
June 1, 1999Foreground/Background Processing1 Introduction to UNIX H. Foreground/Background Processing.
Advertisements

Lecture 4 Shell environment III: - command alias & history; - job control; - editor (vim) CSE4251 The Unix Programming Environment 1.
CIS 118 – Intro to UNIX Shells 1. 2 What is a shell? Bourne shell – Developed by Steve Bourne at AT&T Korn shell – Developed by David Korn at AT&T C-shell.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process The Process A process is.
Introduction to Unix – CS 21 Lecture 10. Lecture Overview Midterm questions Jobs and processes description The foreground and background Controlling jobs.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
LINUX System : Lecture 3 (English-Only Lecture) Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University Acknowledgement.
1 © 2001 John Urrutia. All rights reserved. Chapter 5 The Shell Overview.
1 The Shell and some useful administrative Unix Commands How Unix works along with some additional, useful administrative Unix commands you might need.
Chapter 13 Processes. What is a process? A process is a program in execution A process is created whenever an external command is executed Whenever the.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
Linux+ Guide to Linux Certification, Second Edition
Information Networking Security and Assurance Lab National Chung Cheng University 1 What Linux is? Free Unix Like Open Source Network operating system.
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
5 UNIX Processes. Introduction  Processes  How to list them  How to terminate them  Process priorities  Scheduling jobs  Signals.
1 The Shell and some useful administrative Unix Commands How Unix works along with some additional, useful administrative Unix commands you might need.
UNIX Processes. The UNIX Process A process is an instance of a program in execution. Created by another parent process as its child. One process can be.
Introduction to Unix Bent Thomsen Institut for Datalogi Aalborg Universitet.
Linux in More Detail Shirley Moore CPS5401 August 29,
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Lesson 1. PC vs. Multi-user System  Personal Computer – each user gets his/her own processor (or multicore processor).  Multi-user system – The processor,
Introduction to UNIX Don Bahls user consultant (907)
Introduction to Unix Bent Thomsen Institut for Datalogi Aalborg Universitet.
Command Line Variations Selected Readings in Chapters 3, 5, 6 u Project 1 kickoff u Streams & Redirection: Sections 5.2, 5.3 u Pipes and Tees: Sections.
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface What is the directory tree Some UNIX commands.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
Linux+ Guide to Linux Certification, Third Edition
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
1 Day 10 Process Control. 2 Running a program in the background Here’s a trick: You can actually log onto a UNIX server as many times as you want Try.
Process Control. Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
1 Unix Seminar #1 T.J. Borrelli Lecturer for CS and NSSA February 6th, 2009.
Hands On UNIX II Dorcas Muthoni. Processes A running instance of a program is called a "process" Identified by a numeric process id (pid)‏  unique while.
Lecture 24CS311 – Operating Systems 1 1 CS311 – Lecture 24 Outline Final Exam Study Guide Note: These lecture notes are not intended replace your notes.
1 Lecture 6 Introduction to Process Management COP 3353 Introduction to UNIX.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 9 Working.
Agenda Managing Processes (Jobs) Command Grouping Running jobs in background (bg) Bringing jobs to foreground (fg), Background job status (jobs) Suspending.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
An Introduction to processes R Bigelow. A Unix Process A process in Unix is simple a program The Unix system is made up of a group of processes all interacting.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Process Relationships Chien-Chung Shen CIS/UD
Foreground and background processes
...looking a bit closer under the hood
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Introduction to Shells
...looking a bit closer under the hood
The UNIX Shell Learning Objectives:
Unix Shells.
Hands On UNIX AfNOG 2010 Kigali, Rwanda
The Linux Operating System
Shell Script Assignment 1.
Shell Environments.
Hands On UNIX AfNOG X Cairo, Egypt
Basic UNIX OLC Training.
CS 60 Discussion Review.
The Linux Command Line Chapter 10
...looking a bit closer under the hood
CHAPTER 13 Processes.
CSC 140: Introduction to IT
Shell Programming.
Linux Shell Script Programming
Lab 6: Process Management
Chapter 3 The UNIX Shells
Lecture 6 Introduction to Process Management
Presentation transcript:

Processes and Job Control

Foreground and Background (1)  Unix is a multi-tasking operating system –some of these tasks are being done by other users logged in –some are being done by you in the background  e.g. watching for incoming mail  When you run a task (a Unix command, like ls or vi) it executes in the foreground of your shell –it has the “control" of your screen and keyboard

Foreground and Background (2)  If you still want to use the current shell  obelix[1] > a_heavy_task &  [1]  obelix[2] >  When you put a task in background –task keeps running, but you continue to work at the shell in the foreground –if any output is done, it appears on your screen immediately (can be confusing) –if input is required, process prints a message and stops –when it is done, a message will be printed

Foreground and Background (3)  Explicit background processes are needed less often with windowing systems –Just go to another window and run the command  But explicit background processes are used often in unix –A command needs a long time, you do not want to close that window by accident –Run a job at the background and logout –netscape& will open a new window, but leave the current shell window still available to use

A Simple Script  We use the following shell script to illustrate job control  Edit a file make_noise obelix[1] > cat > make_noise #!/bin/sh while [ 1 ] do date sleep 1 done obelix[2] > chmod u+x make_noise  make_noise then is a shell script repeats to print the time for every second, until you terminate it using Ctrl-c.

Job Control – Suspending Jobs  csh, tcsh, and bash allow you to manage the running of different processes  Suspending jobs –the Ctrl-z special character stops the job obelix[1] > make_noise Fri May 16 14:14:43 EDT 2003 …… ^Z Suspended obelix[2] > vi readme ^Z

Job Control - Monitoring Jobs  The "jobs" command shows which of your jobs are running and/or stopped. obelix[3] > jobs [1] + Suspended make_noise [2] + Suspended vi readme  Here there are two suspended processes, the make_noise and a vi process.

Job Control – Resuming Jobs  Putting jobs back into the foreground: –Use the "fg" command to move a job into the foreground. obelix[4] > fg %2 –Puts job number 2 into the foreground. –Works with either a background or stopped job.  Putting jobs into the background: obelix[5] > bg %1

Job Control – Killing Jobs  Jobs can also be killed –Use the Unix "kill" command obelix[6] > kill %1 or if it won't die... obelix[7] > kill –9 %1  Jobs can be stopped and continued obelix[8] > a_heavy_task & obelix[9] > stop %1 obelix[10] > bg %1

Using ps (1)  Jobs are really just a special case of Unix processes  ps can list the current processes obelix[11] > ps PID TT S TIME COMMAND 2312 pts/0 T 0:00 vi 2296 pts/0 R 0:00 tcsh 2313 pts/0 R 0:00 ps  ps can take many options, depending on which version of ps you are using (/usr/bin/ps vs. /usr/ucb/ps)

Using ps (2)  The ps command takes a number of options  -l gives you a long listing of what is going on  -u loginid tells you about loginid's processes  use man ps to see more options  kill pid kills the process pid –TERM signal will be sent to the process pid –kill -9 or kill -KILL will send the KILL signal –Use man kill to find out more signals

Another useful command: ulimit  The ulimit utility sets or reports the file-size writing limit imposed on files written by the shell and its child processes (files of any size may be read). Only a process with appropriate privileges can increase the limit.  -a prints all limits  -f maximum file size (in 512-byte blocks)  -v maximum size of virtual memory (in kbytes)  Let us illustrate the interest of ulimit shell]$ ulimit -u 100 shell]$ more foo echo FOO./bar shell]$ more bar echo BAR./foo shell]$./foo