CS 497C – Introduction to UNIX Lecture 27: - The Process Chin-Chih Chang

Slides:



Advertisements
Similar presentations
Job and Process Management
Advertisements

June 1, 1999Foreground/Background Processing1 Introduction to UNIX H. Foreground/Background Processing.
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.
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.
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 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.
Process Management We studied process management in chapter 4 – Here, we examine managing processes from a user’s and system administrator’s perspective.
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
Controlling Processes & Periodic Processes WeeSan Lee
Linux+ Guide to Linux Certification, Second Edition
CS 497C – Introduction to UNIX Lecture 34: - Shell Programming Chin-Chih Chang
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 4: Understanding the UNIX Command Chin-Chih Chang
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
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 and Shell Programming (06CS36)
Linux in More Detail Shirley Moore CPS5401 August 29,
Operating Systems Yasir Kiani. 22-Sep Agenda for Today Review of previous lecture Process management commands: bg, fg, ^Z, jobs, ^C, kill Thread.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
1Reference “Introduction To Unix Signals Programming” in the reference material section Man page – sigprocmask, alarm “Understanding the Linux Kernel”
Linux+ Guide to Linux Certification, Third Edition
Additional UNIX Commands. 222 Lecture Overview  Multiple commands and job control  More useful UNIX utilities.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
Process Control. Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions.
Operating Systems Process Management.
SUSE Linux Enterprise Server Administration (Course 3037) Chapter 6 Manage Linux Processes and Services.
Va-scanCopyright 2002, Marchany Unit 7 – Solaris Process Control Randy Marchany VA Tech Computing Center.
Managing processes and services. 1. How Linux handles processes 2. Managing running processes 3. Scheduling processes.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
RH030 Linux Computing Essentials
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.
Guide To UNIX Using Linux Third Edition Chapter 8: Exploring the UNIX/Linux Utilities.
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
Scis.regis.edu ● CS 468: Advanced UNIX Class 4 Dr. Jesús Borrego Regis University 1.
Week Fourteen Agenda Announcements Final Exam True/False -100 questions (1 point per question) Multiple Choice - 40 questions (2 points per question)
Linux+ Guide to Linux Certification Chapter Eleven Managing Linux Processes.
Signals and Signal Processing CIS 370 Lab 7 Umass Dartmouth.
1 Lecture 6 Introduction to Process Management COP 3353 Introduction to UNIX.
UNIX Signals * POSIX-Defined Signals * Signaling Processes * Signal Mask * sigaction * kill and sigaction * alarm * Interval Timers * POSIX.1b Timers *
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.
CS 390 Unix Programming Environment
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop VI Scheduling & Process Management Professional.
S -1 Processes. S -2 wait and waitpid (11.2) Recall from a previous slide: pid_t wait( int *status ) wait() can: (a) block; (b) return with status; (c)
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.
1 Lecture 19: Unix signals and Terminal management n what is a signal n signal handling u kernel u user n signal generation n signal example usage n terminal.
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.
UNIX-21 WEEK 2 4/5/2005. UNIX-22 TOPICS Functions (contd.) pushd, popd, dirs Debugging Shell scripts Scheduling Unix jobs Job Management.
1 COP 4343 Unix System Administration Unit 8: – at – cron.
Running the Operational Codes for the Brahmaputra Tom Hopson.
Processes Todd Kelley CST8207 – Todd Kelley1.
Linux 101: Managing Jobs, Schedules, and Backups Purdue Linux Users Group Speaker: Thor Smith.
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Chapter 11 – Processes and Services
Operating Systems Lecture 12.
Periodic Processes Chapter 9.
Lab 6: Process Management
CST8177 Scripting 2: What?.
Signals.
Lecture 6 Introduction to Process Management
Presentation transcript:

CS 497C – Introduction to UNIX Lecture 27: - The Process Chin-Chih Chang

nice: Job Execution with Low Priority Processes are usually executed with equal priority. The nice command is used with the & operator to reduce the priority of jobs. To run a job with a low priority, the command name is prefixed with nice: nice wc -l manual & nice values are system-dependent and range from -20 to 19 in Linux. A higher nice value implies a lower priority. nice –5 wc –l manual &

Signals A signal is an interrupt generated by the shell or other process in response to some error condition. We can send a signal to the active process with a specific request of termination. After the signal is communicated with the process, the process does one of three things: –Do nothing. –Ignore the signal.

Signals –Trap the signal. The process catch the signal and decides to take some action on the signal. A signal is represented by an integer that presents a particular event: –1 (SIGHUP): Hang up –2 (SIGINT): Terminal interrupt –3 (SIGQUIT): Quit from terminal –9 (SIGKILL): Surest kill –15 (SIGTERM): Default termination signal –24 (SIGTSTP): Suspends process [Ctrl-z]

Signals The complete list of signals applicable to your machine can be found in the file /usr/include/sys/signal.h. In the Linux systems in our department, it is defined in /usr/include/bits/signum.h. SIGQUIT directs a process to produce a core dump (a file named core in the current directory). The SIGKILL signal will surely terminate the process.

kill: Premature Termination of a Process You can terminate a process with the kill command. The kill command uses one or more PIDs as its arguments, and by default uses the SIGTERM signal (15). If the default signal number 15 doesn’t work, then signal 9 will ( kill -9 ). The last background job can be killed with kill $! on most shells.

Job Control If you are using the C shell, Korn shell, or bash, you can use their job control facilities to manipulate jobs. Job control in these shells includes: –Relegate a job to the background (bg). –Bring it back to the foreground (fg). –List the active jobs (jobs). –Suspend a foreground job ([Ctrl-z]). –Kill a job (kill). fg %2 brings the second job to the foreground.

at and batch: Execute later You can schedule a job for one-time execution with the at command, or run it when the system load permits with the batch command. at takes as its argument the time the job is to be executed. $ at 14:08 empawk2.sh [Ctrl-d]

at and batch: Execute later You can also use the -f (file) option to take commands from a file. To mail the job completion to the user, use the -m (mail) option. Jobs can be listed with the at -l (list) command and removed with at -r (remove). The batch command uses an internal algorithm to determine the execution time. batch < empawk2.sh

cron: Running Jobs Periodically cron lets you schedule jobs so that they run periodically. It takes input from a user’s crontab file which is located in /var/spool/cron/crontabs. The file contains six fields separated by whitespace : –The first field specifies the minutes after the hour. –The second field indicates the hour. –The third field controls the day of the month.

cron: Running Jobs Periodically –The fourth field specifies the month. –The fifth field indicates the days of the week. –The last field is the command to be executed * 3,6,9,12 5 find / -size print The find command will executes every minute in the first 10 minutes after 5 p.m., every Friday of the months March, June, September, and December. A * indicates the command is executed every period on the field.

cron: Running Jobs Periodically The crontab command is used to make entries in the crontab file. You can see the contents of your crontab file with crontab -l and remove them with crontab -r. Not every user is able to use the cron facilities. Access to cron services are also controlled by cron.allow and cron.deny in /etc/cron.d or /usr/lib/cron.

time: Timing Processes The time command accepts a command to be timed as its argument and does this work. It executes the program and also displays the time usage on the terminal. This enables programmers to tune their programs to keep CPU usage at an optimum level. time sort –o list invoice Generally, three time information is shown: –The real time shown is the clock elapsed from the command invocation till its end.

time: Timing Processes –The user time shows the time spent by the program in executing itself. –The system time indicates the time used by the UNIX system in doing work. The sum of the user time and the system time actually represents the CPU time.