0
0
Bash Scriptingscripting~20 mins

Disk space monitoring script in Bash Scripting - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Disk Space Monitoring Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Disk usage percentage extraction
What is the output of this command snippet that extracts disk usage percentage for root (/) partition?
Bash Scripting
df / | tail -1 | awk '{print $5}'
A85
B85%
C/dev/sda1
DFilesystem
Attempts:
2 left
💡 Hint
Look at the fifth column of the df output for root partition.
Configuration
intermediate
1:30remaining
Cron job for disk space alert
Which cron job entry runs a disk space check script every day at 6 AM?
A0 6 * * 1 /usr/local/bin/disk_check.sh
B0 18 * * * /usr/local/bin/disk_check.sh
C0 6 * * * /usr/local/bin/disk_check.sh
D6 0 * * * /usr/local/bin/disk_check.sh
Attempts:
2 left
💡 Hint
Cron format is: minute hour day month weekday
Troubleshoot
advanced
2:00remaining
Script fails to send alert email
A disk space monitoring script uses 'mail' command to send alerts but no emails are received. What is the most likely cause?
AThe mail command is not installed or configured properly on the system.
BThe disk usage threshold is set too high in the script.
CThe script does not have execute permission.
DThe disk partition is mounted read-only.
Attempts:
2 left
💡 Hint
Check if the mail command works independently.
🔀 Workflow
advanced
2:30remaining
Disk space alert workflow
Which sequence correctly describes a disk space alert workflow?
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Think about the logical order of checking, comparing, alerting, then logging.
Best Practice
expert
3:00remaining
Efficient disk space monitoring script design
Which practice improves efficiency and reliability of a disk space monitoring script?
ASend alert emails every minute regardless of disk usage changes
BRun multiple df commands separately for each partition to isolate errors
CHardcode disk usage thresholds inside the script without external config
DUse a single df command with parsing to check all relevant partitions at once
Attempts:
2 left
💡 Hint
Minimize system calls and centralize configuration for maintainability.