crontab in Linux (original) (raw)

Last Updated : 23 Jan, 2026

The crontab command in Linux is used to create, edit, and manage scheduled tasks (cron jobs) that run automatically at specified times or intervals. It allows users to automate repetitive system and administrative tasks without manual intervention.

Example: To check the Crontab In System.

Check crontab for scheduling the jobs in Linux.

**Syntax:

systemctl status cron

**Output:

crontab

Shows whether the cron service is active (running), inactive, or stopped.

Working of Crontab

Crontab allows users to schedule commands or scripts to run automatically at fixed times or regular intervals. The following points explain how crontab functions in a Linux system.

Crontab Configuration

Time Specification

Scheduled Execution

Logging and Notifications

System-wide and User-specific Jobs

Syntax:

MIN HOUR DOM MON DOW CMD

Let's break down each field and discuss as follows:

MIN (Minute)

HOUR

DOM (Day of Month)

MON (Month)

DOW (Day of Week)

CMD (Command)

Usage and Examples of Linux Crontab Jobs

Example 1. To View the Crontab entries

1. View Current Logged-In User’s Crontab entries:

**Syntax:

crontab -l

**Output:

viewing the crontab entries

**2. To View Root Crontab entries: Login as root user (su – root)=

**Syntax:

crontab -l

**Output:

no cron jobs are listed

**3. To view crontab entries of other Linux users: Login to root and follow the syntax.

**Syntax:

crontab -u [username] -l

**Output:

Example 2.Edit Crontab Entries for the Current User

To edit a crontab entries, use crontab -e. By default, this will edit the currently logged-in user crontab.

**Syntax:

crontab -e

**Output:

crontab1

Example 3. Scheduling a Job For a Specific Time:

**Syntax:

30 08 10 06 * /home/sujal/myscript.sh

**Output:

crontab8

Example 4. To Schedule a Job for Every Minute using Cron:

Ideally, you may not have a requirement to schedule a job every minute. But understanding this example will help you understand the other examples.

**Syntax:

**Example:

Example 5. To Schedule a Background Cron Job for Every 10 Minutes:

Use the following command, if you want to check the disk space every 10 minutes.

**Command:

*/10 * * * * /home/sujal/myscript.sh

**Output:

crontab4

Keyword Equivalent @yearly 0 0 1 1 * @daily 0 0 * * * @hourly 0 * * * * @reboot Run at startup.

Example 6. To Schedule a Job For More Than One Time

The following script takes an incremental backup twice a day every day. This example executes the specified incremental backup shell script (incremental-backup) at 1:00 and 11:00 every day.

**Command:

00 1,11 * * * /home/sujal/myscript.sh

crontab2

Example 7. To Schedule a Job for a Within Certain Range of Time

**Approach 1: If you wanted a job to be scheduled for every hour within a specific range of time then use the following.

**Command:

0 9 * * 1-5 /home/sujal/myscript.sh

**Output:

crontab3

**Approach 2: 00 – 0th Minute (Top of the hour) 09-18 – 9 am, 10 am, 11 am, 12 am, 1 pm, 2 pm, 3 pm, 4 pm, 5 pm, 6 pm * – Every day * – Every month * – Every day of the week

**Command:

00 09-18 * * 1-5 /home/sujal/myscript.sh

Example 8. To Schedule a Job for the First Minute of Every Year Using @yearly:

If you want a job to be executed on the first minute of every year, then you can use the @yearly cron keyword as shown below.

**Command:

@yearly /home/sujal/myscript.sh

**Output:

crontab5

Example 9. To Schedule a Cron Job Beginning of Every Month Using @monthly:

It is similar to the @yearly as above. But executes the command monthly once using the @monthly cron keyword. This will execute the shell script tape-backup at 00:00 on the 1st of every month.

**Command:

@monthly /home/sujal/myscript.sh

**Output:

crontab6

Example 10. To Schedule a Background Job Every Day Using @daily:

Using the @daily cron keyword, this will do a daily log file cleanup using the cleanup-logs shell script at 00:00 every day.

**Command:

@daily /home/sujal/myscript.sh

**Output:

crontab7

Example 11. To Execute a Command after Every Reboot Using @reboot:

Using the @reboot cron keyword, this will execute the specified command once after the machine gets booted every time.

**Command:

@reboot CMD

Features of Linux Crontab

1. Flexible Scheduling

2. Automated Task Execution

3. User-Specific Configuration

4. Special Time Indicators