0
0
Linux CLIscripting~20 mins

Editing crontab (crontab -e) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Crontab Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this crontab entry?
Given the crontab entry below, what will be the output when it runs?

0 5 * * * echo "Backup started" >> /tmp/backup.log
AThe message "Backup started" is appended to /tmp/backup.log at 5:00 AM daily.
BThe message "Backup started" is printed on the terminal at 5:00 AM daily.
CThe message "Backup started" is overwritten in /tmp/backup.log at 5:00 AM daily.
DThe message "Backup started" is appended to /tmp/backup.log every minute.
Attempts:
2 left
💡 Hint
Remember that '>>' appends output to a file and the schedule '0 5 * * *' means 5:00 AM every day.
📝 Syntax
intermediate
2:00remaining
Which crontab entry is syntactically correct?
Select the crontab entry that will NOT cause a syntax error when saved.
A15 25 * * * /usr/bin/backup.sh
B60 12 * * * /home/user/run.sh
C30 14 * * 1-5 /usr/bin/python3 /home/user/script.py
D0 0 0 * * /usr/bin/cleanup.sh
Attempts:
2 left
💡 Hint
Minutes must be between 0-59 and hours between 0-23 in crontab.
🔧 Debug
advanced
2:00remaining
Why does this crontab entry not run the script?
A user added this line to their crontab:

0 3 * * * /home/user/myscript.sh

But the script does not run at 3 AM. What is the most likely reason?
AThe script /home/user/myscript.sh does not have execute permission.
BThe crontab entry is missing the username field.
CThe time format '0 3 * * *' is invalid.
DCrontab cannot run scripts located in /home directories.
Attempts:
2 left
💡 Hint
Check file permissions and execution rights for scripts run by cron.
🚀 Application
advanced
2:00remaining
Schedule a script to run every 15 minutes using crontab
Which crontab entry correctly runs /usr/local/bin/cleanup.sh every 15 minutes?
A0,15,30,45 * * * * /usr/local/bin/cleanup.sh
B15 * * * * /usr/local/bin/cleanup.sh
C0-15 * * * * /usr/local/bin/cleanup.sh
D*/15 * * * * /usr/local/bin/cleanup.sh
Attempts:
2 left
💡 Hint
Use the step value syntax to run commands at intervals.
🧠 Conceptual
expert
2:00remaining
What happens if you edit crontab with 'crontab -e' and save an empty file?
If a user runs 'crontab -e' and deletes all lines, saving an empty file, what is the effect on their scheduled jobs?
AThe system restores the previous crontab automatically.
BAll scheduled cron jobs for that user are removed and will no longer run.
CCron jobs continue running as before because empty file is ignored.
DAn error is shown and the empty crontab is not saved.
Attempts:
2 left
💡 Hint
Think about what an empty crontab means for scheduled tasks.