Question: 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

 Given the input listed above, the output below displays a list

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.

of the PIDs and CMDs (with all its arguments) of the processes

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!