Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the input listed above, the output below displays a list of the PIDs and CMDs (with all its arguments) of the processes which have

image text in transcribed

Given the input listed above, the output below displays a list of the PIDs and CMDs (with all its arguments) of the processes which have used at least 5 minutes of cumulative CPU time.

image text in transcribed

Part 3. (14 points). More Bash, awk Write a Bash script that processes the output from the ps -ef command. The ps command is used to display the current processes running on the system. The -e option permits all processes currently executing to be displayed and the -f option enables the full-format output listing. The goal is to write a Bash script using awk that produces the similar output as shown in the example below (i.e. processes having used greater than 5 minutes of CPU time). $ cat psdata UID PID PPID C STIME TTY root 0 0 Jan16 ? root 0 0 Jan16 ? root 148 20 Jan16 ? jim 24149 2 0 Jan16 ? jgroven 15387 1 0 Jan29 ? jgroven 153 90 15387 0 Jan29 ? jgroven 15470 1 0 Jan 29 ? jmagersl 30723 14294 0 Jan 30 ? TIME CMD 00:00:15 /sbin/init 00:25:30 [kthreadd] id 35 02:50:20 [bioset] 01:00:10 [kp smous ed] start 00:00:00 /lib/systemd/ systemd --user 00:50:30 (sd-pam) 00:30:06 tmux 00:00:00 [bash] Given the input listed above, the output below displays a list of the PIDs and CMDs (with all its arguments) of the processes which have used at least 5 minutes of cumulative CPU time. - O X 54.213.239.199 - PUTTY /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > ./s1.sh These are the processes which have used over 5 minutes or 300 seconds of CPU time cputime is 1530 seconds used by : PID= 2 CMD= [kthreadd] id 35 cputime is 10220 seconds used by : PID= 148 CMD= [bioset] cputime is 3610 seconds used by : PID= 24149 CMD= [kpsmoused] start cputime is 3030 seconds used by : PID= 15390 CMD= (sd-pam) cputime is 1806 seconds used by : PID= 15470 CMD= tmux /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > Here is a simple example of incorporating awk with regular expressions: $ps -ef awk '$7 -/([2-9][0-9])/ {print $7}' Here are some hints: 1. You may want to incorporate regular expressions. And/or, converting the elapsed time duration to seconds. 2. In your outnut, include the elansed time, the PID and entire CMD as shown above. Part 3. (14 points). More Bash, awk Write a Bash script that processes the output from the ps -ef command. The ps command is used to display the current processes running on the system. The -e option permits all processes currently executing to be displayed and the -f option enables the full-format output listing. The goal is to write a Bash script using awk that produces the similar output as shown in the example below (i.e. processes having used greater than 5 minutes of CPU time). $ cat psdata UID PID PPID C STIME TTY root 0 0 Jan16 ? root 0 0 Jan16 ? root 148 20 Jan16 ? jim 24149 2 0 Jan16 ? jgroven 15387 1 0 Jan29 ? jgroven 153 90 15387 0 Jan29 ? jgroven 15470 1 0 Jan 29 ? jmagersl 30723 14294 0 Jan 30 ? TIME CMD 00:00:15 /sbin/init 00:25:30 [kthreadd] id 35 02:50:20 [bioset] 01:00:10 [kp smous ed] start 00:00:00 /lib/systemd/ systemd --user 00:50:30 (sd-pam) 00:30:06 tmux 00:00:00 [bash] Given the input listed above, the output below displays a list of the PIDs and CMDs (with all its arguments) of the processes which have used at least 5 minutes of cumulative CPU time. - O X 54.213.239.199 - PUTTY /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > ./s1.sh These are the processes which have used over 5 minutes or 300 seconds of CPU time cputime is 1530 seconds used by : PID= 2 CMD= [kthreadd] id 35 cputime is 10220 seconds used by : PID= 148 CMD= [bioset] cputime is 3610 seconds used by : PID= 24149 CMD= [kpsmoused] start cputime is 3030 seconds used by : PID= 15390 CMD= (sd-pam) cputime is 1806 seconds used by : PID= 15470 CMD= tmux /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > /home/jim/Lab3 Yes Master > Here is a simple example of incorporating awk with regular expressions: $ps -ef awk '$7 -/([2-9][0-9])/ {print $7}' Here are some hints: 1. You may want to incorporate regular expressions. And/or, converting the elapsed time duration to seconds. 2. In your outnut, include the elansed time, the PID and entire CMD as shown above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

=+4 How does one acquire a global mindset?

Answered: 1 week ago

Question

=+2 How can the effectiveness of global virtual teams be improved?

Answered: 1 week ago