Crontab Real-World Scenario Quiz

10 scenario-based questions for Sys Admin, DevOps, and SRE practice

Goal: Practice real troubleshooting and scheduling decisions using crontab, including backups, health checks, permissions, logs, root jobs, and overlapping jobs.
Total Questions
10
Answered
0
Score
0
Timer
10:00

Result

Scenario 1 Not answered
Scenario: A Linux server needs to run a backup script every night at 2:00 AM. The script is located at `/opt/scripts/backup.sh`.

Which cron entry is correct?

Explanation: `0 2 * * *` means minute 0, hour 2, every day. So it runs daily at 2:00 AM.
Scenario 2 Not answered
Scenario: Your DevOps team wants to run a health check script every 5 minutes. The script is `/opt/scripts/health-check.sh`.

Which cron expression should you use?

Explanation: `*/5` in the minute field means every 5 minutes.
Scenario 3 Not answered
Scenario: A script works manually, but it does not run from cron. The crontab entry is `* * * * * backup.sh`.

What is the most likely issue?

Explanation: Cron has a limited environment. Use the full path, such as `/home/khalid/scripts/backup.sh`.
Scenario 4 Not answered
Scenario: A backup cron job runs, but you cannot see any output or errors.

What should you add to the cron entry?

Explanation: Use `>> /var/log/backup.log 2>&1` to append output and errors to a log file.
Scenario 5 Not answered
Scenario: Your manager wants a report generated every Monday to Friday at 9:00 AM.

Which cron entry is correct?

Explanation: `0 9 * * 1-5` means 9:00 AM, Monday through Friday.
Scenario 6 Not answered
Scenario: A cron job is scheduled correctly, but the script does not execute. You check the file and see `-rw-r--r--` permissions.

What should you do?

Explanation: The script needs execute permission. Use `chmod +x /opt/scripts/cleanup.sh`.
Scenario 7 Not answered
Scenario: A job needs to clean system cache and requires root permission.

Where should you place the cron job?

Explanation: If a job requires root permissions, schedule it in root's crontab with `sudo crontab -e`.
Scenario 8 Not answered
Scenario: A cron job runs every 5 minutes, but sometimes the previous run is still running when the next one starts.

What should you use to prevent overlapping runs?

Explanation: `flock` uses a lock file so a new run does not start if the previous run is still active.
Scenario 9 Not answered
Scenario: A cron job did not run on an Ubuntu server.

Which command can help check cron logs?

Explanation: On Ubuntu/Debian, cron logs are commonly found in `/var/log/syslog`.
Scenario 10 Not answered
Scenario: Your SRE team wants to run a maintenance script on the first day of every month at midnight.

Which cron expression is correct?

Explanation: `0 0 1 * *` means midnight on the first day of every month.