Company: Amazon Offcampus Sde intern
Difficulty: medium
Assume that you are a Linux system administrator responsible for managing a high-performance web server. You need to implement a Bash script that monitors CPU usage and prints the top three CPU-consuming processes. The script should refresh every 5 seconds and terminate after 1 minute. Which of the following scripts correctly fulfills this requirement? #!/bin/bash duration=60; interval=5 for ((i=0; i<$((duration/interval)); i++)) do ps -eo pid,%cpu,comm --sort=-%cpu | head -n 4 | tail -n 3 sleep $interval done #!/bin/bash duration=60; interval=5 for ((i=0; i<$((duration/interval)); i++)) do top -bn1 | head -n 17 | tail -n 15 | awk '{print $1, $9, $12}' sleep $interval done #!/bin/bash duration=60; interval=5 for ((i=0; i<$((duration/interval)); i++)) do ps -eo pid,%cpu,comm --sort=-%cpu | tail -n 3 | awk '{print $1, $3}' sleep $interval done #!/bin/bash duration=60; interval=5 for ((i=0; i<$((duration/interval)); i++)) do top -bn1 | head -n 12 | tail -n 10 | awk '{print $1,