Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 CSCI 330 T HE UNIX S YSTEM Shell Job Control

2 T ODAY ’ S CLASS Unix is multi-user, multi-process OS Shell features to control jobs Unix utilities to manage jobs crontab at batch 2 CSCI 330 - The UNIX System

3 T ERMINOLOGY process is a program in execution process is created every time you run a command each process has a unique process id processes are removed from the system when the command finishes its execution job is a unit of work consists of the commands specified in a single command line A single job may involve several processes, each consisting of an executable program 3 CSCI 330 - The UNIX System

4 J OB C ONTROL T ERMINOLOGY Foreground job: a job that has our immediate attention user has to wait for job to complete Background job: a job that the user does not wait for it runs independently of user interaction Unix shells allow users to: make jobs execute in the background, move jobs from foreground to background, determine their status, and terminate them 4 CSCI 330 - The UNIX System

5 B ACKGROUND J OBS How do we decide which jobs to place in the background? jobs that are run non-interactively jobs that do not require user input Examples: searching the file system for particular kinds of files solving complex equations compiling long programs backing up the file system 5 CSCI 330 - The UNIX System

6 B ACKGROUND J OBS to execute command in the background, put & after it Example: % date; cd projectc; cc gets.c –o gets & [1] 26432 % 6 CSCI 330 - The UNIX System Job number PID

7 M ANAGING JOBS display jobs command “jobs” lists your active jobs each job has job number job number with “%” is used to refer to job send job to background bg move job to foreground fg 7 CSCI 330 - The UNIX System

8 S IGNALING JOBS send signal to job with kill command Examples: kill -HUP 12324 kill -INT %1 8 CSCI 330 - The UNIX System

9 E NDING JOBS to stop a job kill –STOP resume via “bg” or “fg” command to terminate a job kill kill -INT kill -9 once a job finishes it will display exit status 9 CSCI 330 - The UNIX System

10 S CHEDULING U TILITIES Crontab (= CRON Table) run a job based on a schedule job is executed on a periodic basis at run a job some time in the future batch run a job when system load is low 10 CSCI 330 - The UNIX System

11 P ERIODIC E XECUTION : CRONTAB crontab is based on control file crontab file has 6 columns: minutehourdaymonthweekday command meaning: 1. minute0-59 2. hour0-23 3. day1-31 4. month1-12 5. weekday1-7 (1=Mon,2=Tue, …,7=Sun) 6. commandAny UNIX command “*” means any value 11 CSCI 330 - The UNIX System

12 E XAMPLE : CRONTAB FILE 0 8 * * 1 echo Happy Monday Morning 30 14 * * 1 echo Meeting at 3pm 0 17 * * 5 $HOME/bin/cleanup.sh 12 CSCI 330 - The UNIX System

13 CRONTAB COMMAND options: -eto edit the control file -lto list the control file -rto remove the control file for superuser -uto edit another user’s control file 13 CSCI 330 - The UNIX System

14 O NE T IME E XECUTION : AT UTILITY Use ‘at’ to run a command or list of commands at a later time Must specify on the command the time and date on which your command to be executed Do not have to be logged in when the commands are scheduled to run Syntax: % at timeDate command 14 CSCI 330 - The UNIX System

15 AT UTILITY Can give as much of date as desired If date/time has passed, command will run instantly In case system was down when it was supposed to run Examples: % at 13:45 Wed % at 01:45 pm Sep 18 % at 09:25 Sep 18 2010 % at 09:25 Sep 18, 2010 % at 11:00 pm tomorrow % at teatime # 4:00 pm 15 CSCI 330 - The UNIX System

16 E XAMPLE : AT UTILITY End input list with cntl-D = end-of-text Remember command runs in batch No output on terminal May get email Or just look for side effects % at 08:55 am tomorrow [Return] at> enscript -Pcsl csci330.csh at> commands will be executed using /bin/sh job 1 at Thu Dec 4 08:55:00 2008 16 CSCI 330 - The UNIX System

17 AT UTILITIES atq lists user’s scheduled jobs atrm removes specified job from at queue 17 CSCI 330 - The UNIX System

18 BATCH COMMAND batch schedules job to be performed when system load is low same program as “at” Syntax: % batch command on turing: low means load is less than 1.5 18 CSCI 330 - The UNIX System

19 S UMMARY Shell Job Control foreground / background jobs periodic scheduling with crontab future execution with at low load execution with batch 19 CSCI 330 - The UNIX System


Download ppt "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."

Similar presentations


Ads by Google