0
0
Linux CLIscripting~15 mins

Common cron expressions in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Common cron expressions
📖 Scenario: You are managing a Linux server and need to schedule tasks to run automatically at specific times. Cron jobs help you do this by using cron expressions that tell the system when to run your commands.Understanding common cron expressions will help you automate daily, weekly, and monthly tasks easily.
🎯 Goal: Learn to write common cron expressions for scheduling tasks at specific times and intervals.You will create cron expressions for running commands every minute, hourly, daily at midnight, weekly on Sunday at midnight, and monthly on the first day at midnight.
📋 What You'll Learn
Create variables with exact cron expressions as strings
Use the exact variable names: every_minute, hourly, daily_midnight, weekly_sunday_midnight, monthly_first_midnight
Print each variable to show the cron expression
💡 Why This Matters
🌍 Real World
System administrators and developers use cron expressions to automate backups, updates, and maintenance tasks on servers.
💼 Career
Knowing common cron expressions is essential for roles involving Linux server management, DevOps, and automation scripting.
Progress0 / 4 steps
1
Create cron expression for every minute
Create a variable called every_minute and set it to the string "* * * * *" which means run every minute.
Linux CLI
Need a hint?

This cron expression uses five asterisks separated by spaces to mean every minute of every hour, day, month, and weekday.

2
Add cron expressions for hourly and daily tasks
Add two variables: hourly set to "0 * * * *" to run at the start of every hour, and daily_midnight set to "0 0 * * *" to run daily at midnight.
Linux CLI
Need a hint?

Use zero for the minute field to run at the start of the hour or day.

3
Add cron expressions for weekly and monthly tasks
Add two variables: weekly_sunday_midnight set to "0 0 * * 0" to run weekly on Sunday at midnight, and monthly_first_midnight set to "0 0 1 * *" to run monthly on the first day at midnight.
Linux CLI
Need a hint?

The last field is the day of the week (0 for Sunday). The third field is the day of the month.

4
Print all cron expressions
Print the variables every_minute, hourly, daily_midnight, weekly_sunday_midnight, and monthly_first_midnight each on its own line.
Linux CLI
Need a hint?

Use separate print statements for each variable.