How to Run Cron Jobs Every 5, 10, or 15 Minutes?

The cron job software utility is a time-based job scheduler in Unix-like operating systems for maintaining the software environments to run periodically at fixed times, days, dates, or intervals. The cron job Usually, the cron jobs execute every 5, 10, or 15 minutes.

The aim of this article is to illustrate the procedure to run cron jobs every 5,10, or 15 minutes intervals.

The guideline of this article is specified below:

Let’s start with the basics of cron jobs.

What is CronTab?

The “crontab” is also called the “cron-table” text file. The objective of the “Crontab” file schedules the defined commands for execution periodically. The “Crontab” file can be created, modified, deleted, and viewed using the “Crontab” command.

Moreover, the “Crontab” uses a demon “crond”. This demon runs in the background to check whether any scheduled jobs need to be executed.

Crontab Syntax

The generalized syntax of crontab is written below:

* * * * * command

The syntax contains a total of six fields that are divided into “five asterisks(placeholders)” and the “command”. The first five fields specify the “time”, and the last one indicates the “command” that must be executed.

However, the time is further divided into five fields:

  • 1st* corresponds to minutes(0-59)
  • 2nd* corresponds to hours(0-23)
  • 3rd* corresponds to the day of the month(1-31)
  • 4th* corresponds to the month(1-12)
  • 5th* corresponds to the day of the week(0-7)

Crontab Operators

Furthermore, the characters or operators used in the first five-time fields are discussed in the below table:

OperatorsDescription
*(asterisk)To specify all possible values for a field.
-(hyphen)To specify a range of values.
,(Comma)To specify a list of values.
 /(Slash)To specify a step of values

How to Run Cron Jobs Every 5 Minutes?

The basic syntax to run the cron jobs every five minutes is as follows:

*/5 * * * * command

The command contains the basic components:

  • */5: Identifies every 5 minutes,
  • *(1st asterisk): Indicates every hour.
  • *(2nd asterisk): Denotes every day of the month.
  • *(3rd asterisk): Shows every month.
  • *(4th asterisk): Displays every day of the week.

As for the practical implementation create the new “crontab” file with the help of the command:

$ crontab -e

 Select the first “/bin/nano” editor by typing “1” to create the new cron tab “/tmp/crontab.mdqw6h/crontab” file:

Add the below-mentioned line to the above newly created crontab file in the following way:

*/5 * * * * /home/itslinuxfoss/Documnets/sample.sh

Save the file by pressing the “Ctrl+S” shortcut key and exit it by utilizing the “Ctrl+X” key. Now the “sample.sh” script will execute every five minutes.

Verify the cron job file status using the following command:

$ crontab -e

How to Run Cron Jobs Every 10 Minutes?

Now insert the following line in the above “/tmp/crontab.mdqw6h/crontab” crontab file to run the particular “Extra.sh” cron job every 10 minutes at time intervals:

*/10 * * * * /home/itslinuxfoss/test/Extra.sh

The above command will rub the “Extra.sh” script after every 10 minutes.

How to Run Cron Jobs Every 15 Minutes?

Type the specified line at the end of the crontab file to run the specific “sample1.sh” cron job every 15 minutes of time sequence:

*/15 * * * * /home/itslinuxfoss/Dir1/Sample1.sh

Run the mentioned command to list down all the cron jobs added into the above  “/tmp/crontab.mdqw6h/crontab” crontab file:

$ crontab -l

Alternative method: Using the Comma(,) Operator

The user can also run the specific cron jobs every 5,10, and 15 minutes by utilizing the “comma” operator followed by the below-mentioned series of minutes:

For 5 Minutes:

0,5,10,15,20,25,30,* * * * command

For 10 Minutes:

0,10,20,30,40,50,60 * * * * command

For 15 Minutes:

0,15,30,45,60,75,90 * * * * command

Although Sash(/) operator is quite bitted easy and recommended as compared to writing the above minutes series in the crontab file.

That’s how the cron jobs are run every 5, 10, or 15 minutes.

Conclusion

In Linux, the cron jobs can be run every 5, 10, or 15 minutes by specifying the time sequence using the “slash(/)” or “comma(,)” operator. Add the lines at the end of the crontab file  “*/5 * * * * command”, “*/10 * * * * command”, and “*/5 * * * * command” for running the con jobs every 5,10, and 15 minutes. This article briefly illustrates how to run cron jobs every 5,10, and 15 minutes.