You are on page 1of 10
y at ne conan $ nice -15 we cat soothe priority by 15 units, default value is 20, therefore, nice ai falue ni 7 low becomes : you can see the nice values of the various Processes funning ir . 4 in $s memory using jnelocalhost =~] $ ps -1 | adm (3 | les vo exp perp c par (nrlappa sz WCHAN TTY TIME cu | las 500 3199 2875 0 75 |0| - 1isg wait tty6 00:00:00 est lor 500 3254 3199 0 77/04 - ioae6 = tty6 00:00:00 ps adnin@localhost ~]$ | | In the above output the column with the heading NI denotes the nice value of a eee eee process. 1 Spheduling of processes (or Job control) — Ina multiprogramming system, at any given time, several processes will be competing for the CPU's time. At any instance, only one process will be in the tunning state while others will be in ready or waiting state. The operating system determines how to allocate processor time among all the ready processes. This allocation in referred as scheduling. Scheduling is a fundamental operating system function, [201] at ——————— = =— Example : (a) To terminal the process with process id 97, command is $ kill 97 (b) The command $ kill -9 process Id gives the guarantee that the process would be killed. Itis Stronger signal Cally SIGKILL. (c)_ The command $ kill 0 terminates all current process except your shell. (a) youcan kill your login shell by using any of these commands, (i) $kill -9 $$ # $$ stores PID of current (ii) $kill -9 0 # kills all processes including login shell (ii) $kill -1 0 # kills all processes including login shell 7 Resetting the Process Priorities The priority of a process is decided by a number associated with it. This numberis ———e called 'nice' value of the process. The nice value of a process can range from 0 to 39, with 20 as the default nice value of a process. A user can lower the priority ofhis _ SS SS — es job using the nice command. Note that higher the nice value of a process means lower is its priority. [200] ya coma fe f $ nice -15 wo cat ino priority by 18 Unis, default value is 20, therefore, nice value now becomes guce™ : . an see the nice values of the various processes running in memory using your | Si ie jasngrocarhost -) $ ps -1 { . ju PID PPID C FRI wi} ADDR SZ WCHAN TTY TIME co ' 3199 2875 0 75 |0| - 1158 wait tty6 00:00:00 bast 4 500 gr 500 3254 319912028779 (02) — = 104677 — tty6 00:00:00 ps I I | | | | | | | | adningiocalhost -1$ process. See Wf ising of processes (or Job control) | ee Inthe above output the column with the heading NI denotes the nice value of a a, Ina multiprogramming system, at any given time, several processes will be competing for the CPU's time. At any instance, only one process will be in the running state while others will be in ready or waiting state. The operating system determines how to allocate processor time among all the ready processes. This allocation in referred as scheduling. Scheduling is a fundamental operating system function, [201] le Scheduling refers to a set of policies and machanisms built into the operatin, System that define the order in which the computer system works. Scheduler sei CS the next job to be admitted in the system for processing. — Pnux: provides sophisitiated Coole to schedule a toby foun run. iat a 2 Specitied tim. 18 of day. Ifthe system load varies greatly chrougheut the day, it ae sense to aa . lulg less urgent jobs at a time when the system overheads are low. _ Some main job scheduling commands are at, batch, cron and tim 9.8 at Command —— eS ee Purpose : This command is used to execute the Linux commands at the Specified ——— SSS specitied time. The at command takes time as its argument. Normally input has to be supplied from the standard input. Example : [admin@localhost ~] $ at 17:00 at> echo It is backup time at> *d (Ctrl 4) [admin@localhost ~]$ | I | i I | ! Job 2 at 2012-01-03 17:00 I I \ Observe that on pressing Ctrl d the at command displayed the jo and time of scheduled execution. Once submitted this way, the message would be Bg Ue Oe SONS aceae eee echoed on out terminal at 10.00 A.M sharp. [202] I ngs Pall filename} [-m] time [date] (-1] (-r] Meaning Specifies the file that contains the command to run. Sends mail once the command has been run. Specifies at what time you want the command to be ran Format hh:mm am / pm or a 24-hour clock is used. The below quick times can also be entered : midnight - Indicates the time 12:00 am (00:00). | noon __-_ Indicates the time 12:00 pm. | now ._- Indicates the current day and time. Lo Specifies the date you wish it to be ran on. Format is month, day, year. The following quick days can also be | entered : today _- Indicates the current day. tomorrow Indicates the day following the current day. A Lists the command that have been set to run. Cancels the command that you have set in the past. [admin@localhost ~] $ at -m 11:30 < myfile ——— job 4 at 2012-01-04 11:30 You have new mail in /var/spool/mail/admin \___ladmin@localhost ~1]$ This command runs the commands listed in the ‘myfile’ atl Press enter key a jobnumber, date and time is specified to this job. Example: This command lists each of the scheduled jobs as shown below [admin@localhost ~]$ | [admin@localhost ~) $ at -1 = } 2 2012-01-03 17:00 a admin | 4 2012-01-04 11:00 a admin | | Example : The command to delete job number 4 is [admin@localhost ~] $ at -r 4 9.9 batch Command a The batch command is similar to at command. In this command, we do Not specity i BOAR n= the exact time to execution of our commands (or job) but the ‘system decides the ‘best time for executing our commands See = ay When we submit our jobs using this command, Linux executes our job when itis relatively free and the system load is light. The batch command does not take any arguments. Example : [admin@localhost ~] § batch at> prog4.sh _job 5 at 2012-01-03 15:58 I | | | at> *d (Ctrl d) | ! | on prossing (Ctrl d) the batch command displayed the job Id, date and te we! gubmited Job. af ‘ command yn a system deamon that executes commands at specified times ye command and the scheduling information are appended in a file ated 7 ontabs ‘available in 'Wvar/spoolicron' directory’. ‘cron’ daemon wakes up (every ute) '© check for jobs or commands to be executed at this time crontabs file. wi executing tl them, it goes back to sleep, only to wake up the next minute, ter command (or line) in crontab file has the following entries : rn) Minute (0°59) o out (0-28) ay of ‘the month (1-31) @. month of the year (1-12) day of the week (0-6 with 0 means sunday) () command e) am can be used in any of the first five fields means run for all values of the field. Example : 0 17 * * * backup.sh This line means run script backup.sh at 9.00 p.m everyday. ee Example ; Create a myfile having following contents: [205] 7 admin@localhost 0 10 1 1 * echo Happy New Year 0 17 * * * backup.sh | I I | “d | | [admin@localhost ~]$ I Now, execute the crontab command using the myfile as : admin@localhost ~] $ crontab myfile This contents of myfile are automatically transferred to the var/spooVcron/crontap, 8 directory where they are stored in a file which has the same name as Your login name. There onwards the eron deamon will read ths fle automatically and excoue the commands present in it on a regular basis. The content of current crontab can be displayed on standard output using the following command admin@localhost ~] $ crontab -1 ‘The current crontab can be removed using the following command. admin@localhost ~] $ crontab -r This command is mainly used to perform housekeeping tasks, like removing outdated files or collecting data on system perform housekeeping, like removing outdated files or collecting data on system performance. It's also extremely useful t0 periodically dial up to an Internet mail server to send and retrieve mail. (208) Pia ol oe eal pinbl!_ 7 Tien a a eee ad ve amintiocalhost -] § tine 1s ni | ape pesktop fruit Rahul sumit tree | go output passwd sachin havita nitin gut cutl list listl prgl prg21 prgl4 second sort sortl wel we3 | | | | real om0.18s user 0m0.001s | sys 0om0.003s [admin@localhost ~]$ When the command completes, time will report how long it took to execute the is sanmandin terms of user CPU time, system CPU time, and realtime. [admin@localhost -] $ time 1s I apple } Banana Grapes | Pineapple real 0m0.0095 | | I | user 0m0.001s | sys 0m0.0025 | Th till its N bet, of the user, The sum of the user time and the system time actually r alt S \ Presons hy CPU time, Exercise ne 1 ~~ 8 real time shown s the clock elapsed time from the invocation of the Coy its termination. The user time shows the time spent by the program jn ang 8xaq ‘ut D elf, while sys Indicates the time used by the Linux system in doing work o, ‘ Define Process, Explain the various attributes of a process. Explain spawning and forking process. Explain various process states and their transitions Explain the mechanism of process creation. Explain the init process. What are its responsibilities? Which command can you use to terminate a process? Explain it. Which command can you use to reset the process priority? Explain it, Explain various job scheduling commands. Explain at command with its options. Explain batch, cron, and time command by using example. go00 [208]

You might also like