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

Slides:



Advertisements
Similar presentations
Recitation 8 (Nov. 1) Outline Process & job control Lab 5 Reminder Lab 5: Due Thursday Minglong Shao Office hours: Thursdays 5-6PM.
Advertisements

Using tcpdump. tcpdump is a powerful tool that allows us to sniff network packets and make some statistical analysis out of those dumps. tcpdump operates.
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.
15-213, Fall 06 Outline Shell Lab Processes Signals.
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.
CSCI 330 T HE UNIX S YSTEM Shell Job Control. T ODAY ’ S CLASS Unix is multi-user, multi-process OS Shell features to control jobs Unix utilities to manage.
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.
A Practical Guide to Red Hat ® Linux ®, Third Edition. © 2007 Mark G. Sobell, Prentice Hall,
1 Introduction to UNIX Ke Liu
1 The Shell and some useful administrative Unix Commands How Unix works along with some additional, useful administrative Unix commands you might need.
Process Relationships Chien-Chung Shen CIS, UD
1 Introduction to UNIX 2 Ke Liu
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
CS 311 – Lecture 14 Outline Process management system calls Introduction System calls  fork()  getpid()  getppid()  wait()  exit() Orphan process.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Linux+ Guide to Linux Certification, Second Edition
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.
CS 497C – Introduction to UNIX Lecture 27: - The Process Chin-Chih Chang
Lecture 3  Shell Variables  Shell Command History  Job / Process Control  Directory Control.
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.
UNIX System Administration Handbook Chapter 4. Controlling Processes 3 rd Edition Evi Nemeth et al. Li Song CMSC691X Summer 2002.
Operating Systems Yasir Kiani. 22-Sep Agenda for Today Review of previous lecture Process management commands: bg, fg, ^Z, jobs, ^C, kill Thread.
June 1, 1999Using The C-Shell1 Introduction to UNIX F. Using C Shell Features.
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.
Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University.
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.
Va-scanCopyright 2002, Marchany Unit 7 – Solaris Process Control Randy Marchany VA Tech Computing Center.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
The kernel considers each program running on your system to be a process A process lives as it executes, with a lifetime that may be short or long A process.
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.
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
Linux+ Guide to Linux Certification Chapter Eleven Managing Linux Processes.
Process Models, Creation and Termination Reference –text: Tanenbaum ch. 2.1.
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.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
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.
CSC414 “Introduction to UNIX/ Linux” Lecture 3
Agenda Managing Processes (Jobs) Command Grouping Running jobs in background (bg) Bringing jobs to foreground (fg), Background job status (jobs) Suspending.
Unix System Administration Controlling Processes Chapter 5.
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.
1 CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
Process Relationships Chien-Chung Shen CIS/UD
ULI101 Week 05. Week Overview ● File system links ● Hard and symbolic links ● Process management ● Storage quota information (quota) ● Printing.
Foreground and background processes
...looking a bit closer under the hood
Introduction to Shells
...looking a bit closer under the hood
Rootly Powers and Controlling Processes
Hands On UNIX AfNOG 2010 Kigali, Rwanda
Hands On UNIX AfNOG X Cairo, Egypt
The Linux Command Line Chapter 10
...looking a bit closer under the hood
CHAPTER 8 ( , ) John Carelli, Instructor Kutztown University
CHAPTER 13 Processes.
Shell Programming.
Lab 6: Process Management
Lecture 6 Introduction to Process Management
Presentation transcript:

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

June 1, 1999Foreground/Background Processing2 Performance Objectives: 1. Manipulate Processes and PIDs (ps, ^c, ^z, kill) 2. Run Commands in the Background (fg, bg, &) 3. Move a foreground command to background (^z, bg) 4. Check the status of background jobs (jobs) 5. Terminate a job (^c, ^d, kill) 6. Keep a job alive after logoff (nohup) 7. Suspend a running job

June 1, 1999Foreground/Background Processing3 Processes and PIDs - ps Each command generates an independent process. Each process has a unique process identification number (PID).

June 1, 1999Foreground/Background Processing4 Processes and PIDs - ps Use the ps command to see what processes are running. host% ps PID TT STAT TIME COMMAND 3835 p2 S 0:00 -csh (csh) 3838 p2 R 0:00 ps è PID is the process identifier è TT is the control terminal è STAT is the status of the process

June 1, 1999Foreground/Background Processing5 Processes and PIDs - ps (Con’t) STAT is the status of the process: n R Runnable processes. n T Stopped processes. n P In page wait. n D Non-interruptible wait (waiting for disk etc). n S Sleeping for less than about 20 seconds. n I Idle, sleeping longer than about 20 seconds. n Z Terminated; waiting for parent ("zombie"). (W) indicates process is swapped out.

June 1, 1999Foreground/Background Processing6 Interrupting a Command To "stop" a running interactive process use ^Z. The message “stopped” is displayed. A ps command will reveal the status: host% ps PID TT STAT TIME COMMAND 3835 p2 S 0:00 -csh (csh) 3839 p2 T 0:00 cat 3840 p2 R 0:00 ps

June 1, 1999Foreground/Background Processing7 Foreground Processing - fg Type fg to continue running the stopped job in the foreground. Use jobs to list job numbers and status. host% jobs [1] - Stopped cat > file4 [2] +Running vi file.c

June 1, 1999Foreground/Background Processing8 Background Processing - bg To continue the job in the background use: host% bg %n n Where n is the job number. To initiate a command in the background us the ampersand: è host% CC file.c &

June 1, 1999Foreground/Background Processing9 Terminating Jobs Terminate a stopped command with kill. host% kill pid Use -1 or -9 option to forcefully terminate. host% kill Terminate a running job with ^C Terminate a program waiting for input with a ^d

June 1, 1999Foreground/Background Processing10 Keeping a Job Active - nohup On logout, the C-shell removes child processes running in background. You can terminate the shell before it sends signal 1. Children continue to run and you will be logged off because your login shell has terminated.

June 1, 1999Foreground/Background Processing11 Keeping a Job After Logout Start a foreground process and then logoff. Allow the process to continue to run. è Enter to stop the foreground process, è Execute bg to place process in background, è Run ps -u userid to obtain the pid of your login shell, è Enter kill -9 shellpid to kill the login shell and log off; but leave the process running detached from the terminal. The process must not do any terminal I/O.

June 1, 1999Foreground/Background Processing12 Keeping a Job Active - nohup Include the command nohup (no arguments) in your.logout file. No need to use kill, logout normally. Executed on logout, nohup directs the login shell to not stop child processes. Processes survive because no signal is sent.

June 1, 1999Foreground/Background Processing13 Monitoring for Unwanted Jobs Unwanted processes can consume valuable computer time. Consider including the following command in the.login and.logout files to spot runaway or unwanted processes. è ps -u userid

June 1, 1999Foreground/Background Processing14 End of Module Complete Foreground/Background Processing Exercises