A cron job lets your computer run tasks automatically on a schedule — like an alarm clock for your system. Whether you’re a developer or beginner, this guide will teach you how to use cron jobs to automate your tasks easil.
This guide is for beginners who want to learn how to automate tasks on their computer. Whether you’re a new developer, a student, or just someone who wants their computer to work smarter, learning cron will help you a lot.
What is Cron?
Cron is a tool that helps your computer run tasks at scheduled times. Think of it like a personal assistant that checks what it needs to do every minute.
There are two main parts:
– cron daemon (crond): A program running quietly in the background checking the schedule.
– crontab (cron table): A special text file where you list what commands to run and when.
Each user on a computer can have their own crontab.
How Does Cron Know When to Run a Task?
Cron uses five time fields to decide when to run a command:
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23, 24-hour clock)
│ │ ┌───────────── day of month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of week (0 - 6, Sunday is 0 or 7)
│ │ │ │ │
* * * * * command_to_run
A * means “every” or “any” value.
For example, * * * * * means “every minute of every hour of every day.”
Examples:
It is for run every minute:
* * * * * /path/to/your/command
Run a command every day at 7:30 AM:
30 7 * * * /path/to/your/command
A command for run every Monday at 2:15 PM:
15 14 * * 1 /path/to/your/command
Run a command at midnight on January 1st:
0 0 1 1 * /path/to/your/command
What Can You Make Cron Do?
You can run almost any command you normally type in the terminal, like:
– Show a message: echo “It’s 10 AM!”
– Run a script: python3 /home/user/script.py
– Create folders: mkdir /home/user/folder_$(date +\%Y-\%m-\%d)
Your First Cron Job
1. Open terminal and type:
crontab -e
2. If asked, choose a text editor .
3. Add this line to create a file on your Desktop every minute:
* * * * * echo "Hello from Cron $(date)" >> ~/Desktop/cron_test.txt
4. Save and exit.
5. Wait a minute and check your Desktop for the cron_test.txt file.
6. To see your current cron jobs, run:
crontab -l
7. To remove the job, edit again (crontab -e) and delete the line.
Important Tips:
– Always use full paths for commands, e.g. /usr/bin/python3 instead of just python3.
– Cron runs with fewer environment variables, so scripts that work in terminal might need adjustments.
– Redirect output and errors to a log file to avoid missing messages:
* * * * * /path/to/command >> /path/to/logfile.log 2>&1
Why Use Cron?
Automate repeated tasks so you don’t forget.
Run backups or updates during off-hours.
Clean files or check system health automatically.
Collect data regularly from websites or APIs.
Try These Ideas:
Add a daily log entry:
0 8 * * * echo "Log entry at $(date)" >> ~/Desktop/daily_log.txt
Create a reminder script to run every 2 hours on weekdays:
Write a file reminder.sh with:
#!/bin/bash
echo "Time to take a break!" > ~/Desktop/REMINDER.txt
Make it executable:
chmod +x ~/reminder.sh
Add to cron:
0 9-17/2 * * 1-5 /home/yourusername/reminder.sh
Conclusion
Cron is a powerful and easy way to automate tasks on your Linux or macOS computer. Once you understand how to schedule jobs and write commands, you’ll save time and make your computer work smarter for you!
Next Steps
- Follow our DevOps tutorials
- Explore more DevOps engineer career guides
- Subscribe to InsightClouds for weekly updates

Subscribe our DevOps youtube channel