How to schedule automated tasks on your computer using Cron Jobs: Complete Guide
Automating recurring technical tasks is one of the most effective ways to save time, eliminate human error, and keep system environments healthy. Whether you need to back up a database every midnight, clear temporary files hourly, or trigger a custom Python script every weekday morning, Cron Jobs are the industry standard on Linux and macOS operating systems.
In this guide, you will learn how the Cron utility works, how to edit your crontab table safely, and how to build 100% valid schedules visually without memorizing complex syntax.
What is a Cron Job?
A Cron job is a background task scheduled to run automatically at specific times or intervals. The daemon process, known as crond, runs continuously in the background of your system and checks your personal configuration file (crontab) every minute.
Structure of a Cron Expression
A standard Cron expression consists of 5 fields separated by spaces:
# Minute Hour DayOfMonth Month DayOfWeek Command
* * * * * /path/to/script.sh
- Minute (0 to 59): The specific minute of the hour when the command executes.
- Hour (0 to 23): The hour of the day in 24-hour format.
- Day of Month (1 to 31): The specific day of the calendar month.
- Month (1 to 12): The month of the year (1 for January, 12 for December).
- Day of Week (0 to 6): The day of the week (0 for Sunday, 1 for Monday, up to 6 for Saturday).
Essential Commands to Manage Crontabs
To view or edit your recurring tasks in the terminal, use the following commands:
crontab -l
Lists all active cron jobs scheduled for your current user.
crontab -e
Opens your personal crontab file in your default terminal editor (Nano or Vim).
WARNING: THE COMMAND crontab -r WILL PERMANENTLY DELETE ALL YOUR SCHEDULED CRON JOBS WITHOUT ASKING FOR CONFIRMATION. ALWAYS BE CAREFUL WHEN TYPING CRONTAB COMMANDS.Practical Examples of Cron Schedules
- Every minute:
* * * * * - Every 15 minutes:
*/15 * * * * - Every day at midnight:
0 0 * * * - Weekdays (Mon-Fri) at 09:00 AM:
0 9 * * 1-5 - First day of every month at midnight:
0 0 1 * *
Build and Test Cron Expressions Visually
Writing cron expressions manually can lead to subtle bugs or missed executions. You can use our free Cron Expression Generator to visually build schedules, translate them into natural language, and simulate the exact upcoming execution dates locally in your browser.