If you’ve ever wanted your computer or server to do something automatically — like back up files every night or run a script every hour — then crontab is the tool you need.
In this post, we’ll explain what crontab is, how it works, and how you can use it to save time and automate tasks.
What Does “Crontab” Mean?
Crontab stands for “cron table.” It’s a file that tells the computer what tasks to run and when to run them.
These tasks are called cron jobs, and they run in the background at the times you choose.
How Crontab Works?
Crontab uses a special format called a cron expression. This expression tells the system when to run a command.
Here’s an example:
0 9 * * * /home/user/backup.sh
This means:
Run the file backup.sh
every day at 9:00 AM.
Opening and Editing Crontab
To open your crontab and add a new task, just type this in the terminal:
crontab -e
This opens your crontab file in an editor. You can then add a new line for each task you want to run.
To see your existing crontab tasks:
crontab -l
To delete all your scheduled tasks:
crontab -r
(Be careful — this removes everything!)
Crontab Format: What Do the Numbers Mean?
Each line in crontab has 5 time fields followed by the command you want to run:
* * * * * command
| | | | |
| | | | +---- Day of the week (0–7)
| | | +------ Month (1–12)
| | +-------- Day of the month (1–31)
| +---------- Hour (0–23)
+------------ Minute (0–59)
For example:
0 * * * *
= Every hour0 0 * * *
= Every day at midnight*/10 * * * *
= Every 10 minutes
What Can You Do with Crontab?
With crontab, you can schedule all kinds of tasks, like:
- Backing up your website or database
- Sending emails or reports
- Running scripts or commands automatically
- Cleaning up old files
Why Use Crontab?
Crontab is useful because it saves time and helps you stay organized. Once you set it up, it runs your tasks for you — no need to remember or do them manually.
Final Thoughts
Crontab is a simple but powerful tool that lets you automate tasks on your server or computer. If you work with Linux, manage websites, or just want to automate something, learning how to use crontab is a great first step.