Lecture 5: Jobs and Processes

Similar documents
CS Unix Tools. Fall 2010 Lecture 10. Hussam Abu-Libdeh based on slides by David Slater. September 29th, 2010

07 - Processes and Jobs

Study Guide Processes & Job Control

Programs. Program: Set of commands stored in a file Stored on disk Starting a program creates a process static Process: Program loaded in RAM dynamic

elinks, mail processes nice ps, pstree, top job control, jobs, fg, bg signals, kill, killall crontab, anacron, at

elinks, mail processes nice ps, pstree, top job control, jobs, fg, bg signals, kill, killall crontab, anacron, at

Processes. System tasks Campus-Booster ID : **XXXXX. Copyright SUPINFO. All rights reserved

Removing files and directories, finding files and directories, controlling programs

(MCQZ-CS604 Operating Systems)

Mid Term from Feb-2005 to Nov 2012 CS604- Operating System

Most of the work is done in the context of the process rather than handled separately by the kernel

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2.

File system links. Week Overview. Hard and symbolic links Process management

Operating Systems Lab 1 (Users, Groups, and Security)

Linux System Administration

System Administration

Computer Systems and Architecture

bash, part 3 Chris GauthierDickey

The Unix Shell. Job Control

Unix Processes. What is a Process?

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

Process Management forks, bombs, zombies, and daemons! Lecture 5, Hands-On Unix System Administration DeCal

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

Chapter 9: Process management. Chapter 9 Process management

ACS Unix (Winter Term, ) Page 92

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

LPI Linux-Linux Advanced Administration.

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Command-line interpreters

Multi-Level Feedback Queues

CS 4410, Fall 2017 Project 1: My First Shell Assigned: August 27, 2017 Due: Monday, September 11:59PM

CS370 Operating Systems

5/8/2012. Controlling User Processes Chapter 10

Systems Programming/ C and UNIX

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

UNIX Quick Reference

Computer Systems and Architecture

Introduction to UNIX Shell Exercises

Lab 4. Out: Friday, February 25th, 2005

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Activity Logging Lecture 16

Lab 2: Linux/Unix shell

The Unix Shell & Shell Scripts

Simplest version of DayOfYear

Bamuengine.com. Chapter 7. The Process

CS 213, Fall 2001 Lab Assignment L5: Writing Your Own Unix Shell Assigned: Oct. 25, Due: Fri., Nov. 2, 11:59PM

Process States. Controlling processes. Process states. PID and PPID UID and EUID GID and EGID Niceness Control terminal. Runnable. Sleeping.

CSE 391 Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

PROCESSES. At least they re not ISO-9001 processes

B a s h s c r i p t i n g

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

Chap2: Operating-System Structures

CSCI Computer Systems Fundamentals Shell Lab: Writing Your Own Unix Shell

UNIX Tutorial Five

CSE 390a Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

Basic Shell Commands

Multitasking. In this chapter: Running a Command in the Backg round Checking on a Process Cancelling a Process

Getting started with Hugs on Linux

CS 213, Fall 2002 Lab Assignment L5: Writing Your Own Unix Shell Assigned: Oct. 24, Due: Thu., Oct. 31, 11:59PM

File system Security (Access Rights)

OPERATING SYSTEMS LINUX

Shells and Processes. Bryce Boe 2012/08/08 CS32, Summer 2012 B

The Unix Shell. Job Control

unix intro Documentation

HW 1: Shell. Contents CS 162. Due: September 18, Getting started 2. 2 Add support for cd and pwd 2. 3 Program execution 2. 4 Path resolution 3

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009

! The Process Control Block (PCB) " is included in the context,

CS 307: UNIX PROGRAMMING ENVIRONMENT REVIEW FOR EXAM 2

Getting started with Hugs on Linux

Oxford University Computing Services. Getting Started with Unix

CS-537: Midterm Exam (Fall 2008) Hard Questions, Simple Answers

Sperimentazioni I LINUX commands tutorial - Part II

8434 User's Guide. Display A built-in 2-line by 24-character display.

UNIX Quick Reference

Each terminal window has a process group associated with it this defines the current foreground process group. Keyboard-generated signals are sent to

CS 0449 Project 4: /dev/rps Due: Friday, December 8, 2017, at 11:59pm

CS125 : Introduction to Computer Science. Lecture Notes #11 Procedural Composition and Abstraction. c 2005, 2004 Jason Zych

Exploring UNIX: Session 5 (optional)

Introduction to the Linux Command Line January Presentation Topics

File permission u owner of file/directory (user) g group of the file/directory o other a all

CRUK cluster practical sessions (SLURM) Part I processes & scripts

Lecture 6: Using BASH Effectively

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

Log Correlation Engine 4.4 Statistics Daemon Guide. February 26, 2015 (Revision 1)

Linux for Beginners. Windows users should download putty or bitvise:

2 Processes. 2 Processes. 2 Processes. 2.1 The Process Model. 2.1 The Process Model PROCESSES OPERATING SYSTEMS

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

Unix Tutorial Haverford Astronomy 2014/2015

Touring the Mac S e s s i o n 4 : S A V E, P R I N T, C L O S E & Q U I T

Chapter. Basic Administration. Secrets in This Chapter. Monitoring the System Viewing Log Files Managing Services and Programs Monitoring Disk Usage

CS197U: A Hands on Introduction to Unix

Systems Programming/ C and UNIX

Jan 20, 2005 Lecture 2: Multiprogramming OS

Linux Command Line Primer. By: Scott Marshall

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

Advanced Bash Scripting

CS 326: Operating Systems. Networking. Lecture 17

Linux Essentials. Smith, Roderick W. Table of Contents ISBN-13: Introduction xvii. Chapter 1 Selecting an Operating System 1

CSE 120 Principles of Operating Systems Spring 2017

REVIEW OF COMMONLY USED DATA STRUCTURES IN OS

Transcription:

Lecture 5: and CS2042 - UNIX Tools October 8, 2008 and

Lecture Outline 1 2 Manipulating and

Intro to Definition: A process is an instance of a running program. More specific than a program because it s being executed! More specific than a running program because the same program can be run multiple times simultaneously! Example: Many users could be simultaneously running ssh to connect to other servers. In this case, each instance of ssh is a separate process. and

Process Identification How do we tell one process from another? Each process is assigned a unique Process ID (or PID) when it is created. These PIDs are used to differentiate between separate instances of the same program. How do we find out which processes are running, and with which PIDs? The Process Snapshot (PS) Command ps [options] Reports a snapshot of the current running processes, including PID and

More PS Options Default: ps Lists processes started by the user from the current terminal All : ps -e Verbose: ps -ely Lists every process currently running on the system Gives more info about your processes than you ll ever need See manpages for details - options for the BSD version are different! and

Lecture Outline 1 2 Manipulating and

Priority Even though UNIX seems to run tens or hundreds of processes at once, one CPU can only run one process at a time. Quick switching back and forth between processes makes it seem as though they are running simultaneously. What if we need a process to get more (or less) time on the CPU than others? The UNIX developers saw this coming - each process is given a priority value when it starts. and

Initial Priority Start a new process with a non-default priority: The Nice Command nice [options] [command] Runs [command] with a specified niceness value (default: 0) Niceness values range between -20 (highest priority) and 19 (lowest priority) Example: Only root can give a process a negative niceness value! nice -n 10 azureus Keeps torrent downloads from hogging all our CPU time! and

Adjusting Priority Adjust the niceness of a running process: The Renice Command renice <priority> -p <PID> Example: Changes the niceness of the indicated process to <priority> Again, only root can go below 0! Can only renice processes YOU started! renice 5 -p 10275 Sets the niceness of the process with PID 10275 to 5 (slightly lower priority than default) and

Lecture Outline 1 2 Manipulating and

Rogue Ctrl+C ends programs that are running in the foreground. What about a background process that stops working? What is the UNIX version of CTRL+ALT+DELETE? and

The Kill Command Kill kill [-signal] <PID> Sends the specified signal to the process By default, terminates execution So, to terminate a process: Look up the process s PID with ps Use that PID to kill the process! and

Useful Signals Signals used with kill can either be specified by their names or numeric values. TERM or 15 : Terminates execution (default) HUP or 1 : Hang-up (restarts the program) KILL or 9 : Like bleach, can kill anything Generally speaking, the default TERM will get the job done. Example: kill 9000 : Terminates process 9000 kill -9 3200 : REALLY kills PID 3200 kill -HUP 12118 : Restarts 12118 (handy for servers & daemons) and

Lecture Outline Manipulating 1 2 Manipulating and

Intro to Job Control Manipulating A job is a process running under the influence of a job control facility. What does this mean?! Job control is a built-in feature of most shells, allowing the user to pause and resume tasks, as well as run them in the background (so that the shell is usable while it executes!) and

How Does This Help? Manipulating Let s use the ping command as an example. Ping ping <server> Measures the network response time (or network latency) to a remote server. Sends short bursts to the server, then measures the time until they are returned. Can be a good way to check your network connection. Try pinging a reliable location, like google.com! Example: ping google.com and

Why We Need Job Control Manipulating As long as ping runs, we lose control of our shell. This happens with many applications which run either indefinitely or for long periods: Example: Moving large quantities of files Compiling source code Playing multimedia play mixtape.mp3 Takes over the shell until the mp3 finishes To listen to music while we work, we need job control! and

Lecture Outline Manipulating 1 2 Manipulating and

Starting a Job in the Background Manipulating To run a job in the background, we will use a new command-line operator: the ampersand (&) & Usage: <command> [arguments] & Runs the specified command as a background job Unless told otherwise, will send output to the terminal! Since cat runs indefinitely with no arguments, this will illustrate our point: Example: cat & Try it without the &! and

Backgrounding a Running Job Manipulating What if we started a process normally and it s taking too long? Pausing a Job Press CTRL+Z to pause a running process! When we do this, the shell tells us the paused job s Job ID This Job ID is used like a process s PID Once we have a process paused, we can tell it to continue in the background and

The Background Command Manipulating bg s Usage bg <Job ID> Resumes a paused job in the background How do we find these Job IDs? The Job Table jobs jobs Prints currently running, paused, or recently stopped Prints jobs with their Job IDs and

Foregrounding an Existing Job Manipulating What if we want to resume a job in the foreground? fg s usage fg <Job ID> Resumes a paused job in the foreground To kill a job, either foreground it and then hit CTRL+C, or you can use the kill command with the Job ID. and

Dealing with Excess Output Manipulating Certain programs output continuously as they run. For example, ping and play both clutter up the terminal with output even when they are backgrounded. Example: The solution? Output redirection! ping google.com > testping.log & When you care about a program s output, redirect it to a log file. Example: play a song.mp3 > /dev/null & If the text output doesn t matter, redirect it to /dev/null. and

/dev/null Manipulating /dev/null is a special file which has the following properties: Any user can write to it. Anything written to it goes nowhere. It always reports a successful write. It works like a black hole for data - you can output to it all day and it will never fill up. Anything you redirect to /dev/null just disappears. and