In: Computer Science
1) In no less than 100 words, describe a situation
where you would want to kill a process?
2) Give an example of when the pstree command would be
helpful.
3) Provide an example of when you would want to run a process as a
background process.
4) Which NICE priority is the fastest priority? Which is exactly in
the middle?
5) Discuss a command that an administrator would want to schedule
on Friday of every week. Give an example of the command.
6) Describe the difference between the "at" and "cron" commands.
What is an equivalent application in MS Windows?
7) Provide a CRON entry for scheduling the script /root/testscript
to run every Thursday at 11:05 AM.
1 .Kill Process:
When a process misbehaves, you might sometimes want to terminate or kill it
.Each process you start is usually completed within a few seconds. Sometimes a background process or a process without a controlling terminal hangs up and you will need to destroy this process by killing it.
Infinite Loop:
An infinite loop is a looping construct that does not terminate the loop and executes the loop forever.
for(; ;)
{ // body of the for loop
. }
If you are executing it, and that too on linux terminal, then
Ctrl
+Z
or
Ctrl
+C
work fine. It would kill/stop the
process and you can make your changes accordingly.
2) Give an example of when the pstree command would be helpful.
Since every process (except the very first one) in a Linux system has a parent, it sometimes makes things easier to understand if all processes are displayed in a tree structure. You'll be glad to know there exists a command line utility - dubbed pstree - that displays a tree of processes.
pstree is a Linux command that shows the running processes as a tree.
It is used as a more visual alternative to the ps command. The
root of the tree is either init or the process with the given
pid.
pstree visually merges identical branches by putting them in square
brackets and prefixing them with the repetition count.
Example
To see a tree diagram of all the processes currently on the server, type:
# pstree
# pstree | less
# pstree | more
At the top of the diagram, you will the process init which is
the first process that is started when Linux comes on line. init is
the parent of all processes on the system, it is executed by the
kernel and is responsible for starting all other processes. You can
use ASCII characters to draw the tree by passing the -A
option:
# pstree -A
3) Provide an example of when you would want to run a process as a background process.
To run a program in the background, enter the command for that job, followed by the & sign.
This returns the Unix prompt to you and executes the job while still allowing you to interact with your terminal. Jobs may be switched from foreground to background and vice versa.
When you run a job in the background, the shell will respond with a number. This number is the "process identification number", or PID. It is useful if you want to halt, or `kill' the program.
example Garbage Collection:
Garbage Collection is removes the unused objects from the memory .It is run as the Background Process .It provides the services to background supportive tasks .
It Act as Deamon threads if all services stop their working background process automatically stop working.
4) Which NICE priority is the fastest priority? Which is exactly in the middle?
nice
is a program found on Unix
and Unix-like operating systems such as Linux.
It directly maps to a kernel call of the same name.
nice
is used to invoke a utility or shell script
with a particular CPU priority, thus giving the process more or
less CPU time than other processes.
The Nice priorty 0 is the fastest priority the range of NICE priority is -20t0 +20 the middle which is exactly in middle.
5) Discuss a command that an administrator would want to schedule on Friday of every week. Give an example of the command.
You can use the at command to schedule a command, a script, or a program to run at a specified date and time. You can also use this command to view existing scheduled tasks.
To use the at command, the Task Scheduler service must be running, and you must be logged on as a member of the local Administrators group.
When you use the at command to create tasks, you must configure the tasks so that they run in the same user account.
The at command uses the following syntax:
at \\computername time/interactive | /every: date, ...
/next: date, ... command
at \\computername id/delete | /delete /yes
The following list describes the parameters that you can use with the at command:
\computername: Use this parameter to specify a remote computer. If you omit this parameter, tasks are scheduled to run on the local computer.
time: Use this parameter to specify the time when the task is to run. Time is specified as hours: minutes based on the 24-hour clock. For example, 0:00 represents midnight and 20:30 represents 8:30 P.M.
/interactive: Use this parameter to allow the task to interact with the desktop of the user who is logged on at the time the task runs.
/every: date,... : Use this parameter to schedule the task to run on the specified day or days of the week or month, for example, Friday of every week Specify date as one or more days of the week (use the following abbreviations: M,T,W,Th,F,S,Su) or one or more days of the week(use the numbers 1 through 7). Make sure that you use commas to separate multiple date entries. If you omit this parameter, the task is scheduled to run on the current day.
Examples of at command:
1.Schedule a job for the coming Monday at a time twenty minutes later than the current time:
at Monday +20 minutes
2. Schedule a job to run at 1:45 Aug 12 2020:
at 1:45 081220
6) Describe the difference between the "at" and "cron"
commands. What is an equivalent application in MS
Windows?
at command:
At is the one-shot At a certain time (tommarrow at 14:00 AM)job is started Once At schedule the task at only once
Schedule a job for the coming Monday at a time twenty minutes later than the current time:
at Monday +20 minutes
.cron command:
CRON command running the task in regular base.(every hour,day,first of the month)
cron job is used to maintain the daily routing work.
cron is used in ETL project in UNIX Envoirment to schedule recurring jobs as per desired time mode without tedious in nature.
The windows equivalent to a cron job is a scheduled task.
With Scheduled Tasks, you can schedule any script, program, or document to run at a time that is most convenient for you. Scheduled Tasks starts every time that you start Windows XP and runs in the background, and it starts each task that you schedule at the time that you specify when you create the task