0
0
Linux CLIscripting~15 mins

crontab syntax in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding Crontab Syntax
📖 Scenario: You are managing a Linux server and want to schedule tasks to run automatically at specific times. To do this, you will learn how to write crontab entries that tell the system when to run your commands.
🎯 Goal: Build a simple crontab entry that runs a backup script every day at 2:30 AM.
📋 What You'll Learn
Create a crontab line with the correct time fields
Use the exact time 2:30 AM for scheduling
Specify the command to run the backup script located at /usr/local/bin/backup.sh
Print the final crontab line to verify
💡 Why This Matters
🌍 Real World
System administrators use crontab to schedule backups, updates, and maintenance tasks automatically without manual intervention.
💼 Career
Knowing crontab syntax is essential for Linux system administrators, DevOps engineers, and anyone managing servers to automate routine tasks efficiently.
Progress0 / 4 steps
1
Set up the time fields for the crontab entry
Create five variables named minute, hour, day_of_month, month, and day_of_week with these exact values: minute = '30', hour = '2', day_of_month = '*', month = '*', and day_of_week = '*'.
Linux CLI
Need a hint?

Remember, crontab time fields are minute, hour, day of month, month, and day of week.

2
Set the command to run in the crontab entry
Create a variable called command and set it to the string '/usr/local/bin/backup.sh' which is the path to the backup script.
Linux CLI
Need a hint?

The command is the exact path to the script you want to run.

3
Combine the time fields and command into one crontab line
Create a variable called crontab_line that combines minute, hour, day_of_month, month, day_of_week, and command separated by spaces in this exact order: minute, hour, day_of_month, month, day_of_week, command.
Linux CLI
Need a hint?

Use an f-string to join all parts with spaces.

4
Print the final crontab line
Write a print statement to display the value of crontab_line.
Linux CLI
Need a hint?

The output should show the full crontab line exactly.