---
title: "Scheduling tasks with cron and crontab in Linux"
description: "Cron is a time-based job scheduler used for automating and scheduling repetitive tasks, periodical collection of data, alerts, etc. The cron daemon or crond allows users to manage and run tasks automa..."
url: https://www.stackscale.com/blog/cron-crontab-linux/
date: 2024-01-11
modified: 2026-08-31
author: "Marketing Stackscale"
image: https://www.stackscale.com/wp-content/uploads/2024/01/cron-crontab-in-Linux-Stackscale-Grupo-Aire.jpg
categories: ["Systems"]
tags: ["Linux"]
type: post
lang: en
---

# Scheduling tasks with cron and crontab in Linux

**Cron** is a time-based job scheduler used for automating and scheduling repetitive tasks, periodical collection of data, alerts, etc. The **cron daemon or crond** allows users to manage and run tasks automatically at specific time intervals. It is one of the key tools for scheduling tasks in Linux and Unix-like operating systems.

## Cron

**Cron** is a command-line utility intended to schedule tasks or “**cron jobs**” to be run periodically and automatically, at a particular time and date. This task manager can be used for numerous purposes, such as:

- Collecting system logs.
- Creating [backups](https://www.stackscale.com/blog/backups/).
- Downloading email or files from the Internet.
- Scheduling system maintenance.
- Synchronizing files.

Tasks run in the background, without altering any Linux functionality. Users can set up an endless list of cron jobs to be executed as scheduled — every n-th minute, hour, day, month or year. The list of tasks is stored in a file called crontab.

## Crontab

**Crontab**, short for “cron table”, is both a command and the file that contains the cron jobs that the cron daemon must periodically run. Every user has its own configuration file and manages his own scheduled jobs. The tasks listed in the crontab file contain the commands along with their date and time of execution. So that the Linux cron utility can run the scripts as scheduled when accessing and analyzing the file.

## Cron jobs

Cron jobs have the following syntax:

```
min  h  d/m  mon  d/w  
```

They are formatted using the following fields:

| **Field** | **Values** |
| --- | --- |
| min (minute) | 0-59 |
| h (hour) | 0-23 |
| d/m (day of the month) | 1-31 |
| mon (month) | 1-12 |
| d/w (day of the week) | 0-6 (Sunday to Saturday) |
| Command | The [Linux command](https://www.stackscale.com/blog/linux-commands/) the user wishes to schedule. |

As well as diverse special characters, such as:

| **Special character** | **Purpose** |
| --- | --- |
| `*` | Select every possible value in a field. *The asterisk can be used to fill a field without any specific value, as all fields must be filled when creating a cron job. |
| `/` | Specify an interval of time. |
| `,` | Select multiple values. |
| `-` | Specify a range of time. |

### Examples of cron jobs scheduled in crontab

- Run the command every day at half past midnight:

```
30  0  *  *  *  
```

- Run the command every Saturday at 2:00AM:

```
0  2  *  *  6  
```

- Run the command at midnight the first day of January:

```
0  0  1  1  *  
```

- Run the command every five minutes from Monday to Friday:

```
*/5  *  *  *  1-5  
```

## Crontab shortcuts

Moreover, in order to simplify commonly used schedules, there are some shortcuts or special commands available:

| **Shortcut** | **Schedule** |
| --- | --- |
| `@reboot` | Run a task when the system restarts. |
| `@yearly` or `@annually` | Run a task once a year. |
| `@monthly` | Run a task the first day of every month (`0 0 1 * *`). |
| `@weekly` | Run a task the first day of every week (`0 0 * * 0`). |
| `@daily` or `@midnight` | Run a task every day at midnight (`0 0 * * *`). |
| `@hourly` | Run a task once an hour (`0 * * * *`). |

![Cron jobs cheat sheets: special characters and crontab shortcuts](https://www.stackscale.com/wp-content/uploads/2024/01/cron-jobs-syntax-and-shortcuts-stackscale-1024x1024.jpg)

## Crontab command

In order to manage scheduled jobs, the following options can be added to the `crontab` command:

- `-e` to edit the current crontab file.
- `-l` to get a list of all the tasks within the current crontab file.
- `-r` to permanently delete the current crontab file.
- `-u <user> <option>` to run an option in another user’s crontab file.

## Scheduling a backup is not the same as having one

Writing the cron job is the easy part. What decides whether a scheduled copy is worth anything is where it lands and how quickly it can be restored, and that is a question of infrastructure rather than syntax. On a [managed Disaster Recovery and backup solution](https://www.stackscale.com/solutions/disaster-recovery-backup/) the storage is geo-replicated between European data centers and carries its own snapshot policy, so the recovery point does not depend on a single scheduled job running as expected.

Need help with servers and systems administration? Our [managed services](https://www.stackscale.com/products/managed-services/) include direct access to specialized technical support. Let’s talk.
