Skip to content

How to run a Cron Job every 15 minutes?

  • by
  • 3 min read

Linux or Unix Operating System provides you with a time-based scheduling service known as Cron. When you want a specific process to run after some time interval, say, after every 30 minutes or an hour, you can schedule a Cron job. In this article, we will see how to run a cron command every 15 minutes.

Crontab file

Crontab file stands for Cron table file and is used to schedule and run the cron jobs. The crontab file is not available by default in the system. You can create a crontab file using the following command.

crontab -e

When you run this command, it asks you to choose a text editor. You can choose the text editor as per your choice. After the file is created, you can write all of your cron jobs into the file, with each cron job specified in a new line.

Syntax of a cron job

While writing your cron jobs, you need to maintain the syntax required for running the cron jobs. You specify the time and then the command you want to execute. The time is divided into five fields – minutes, hour, day of the month, month, and the day of the week, respectively.

* * * * * command

Operators you can use to mention time

There are four operators which you can use to specify the time.

* This is the asterisk operator, and it means that all the values are allowed. If you have this operator in the day field, then the job will run every day.
, The comma operator allows you to specify a list of values on which the job should run. For example, in the month field, you can specify the month number separated with a comma to execute the job on those specific months.
The hyphen operator allows you to specify a range of values with both the first and last values included. If in the hour field you specify 8-13, then the job will run from 8 in the morning till 13 noon every hour.
/ This is the slash operator. You use it to specify the step value after which the job should run. For example, if you specify */3 in the hour field, the job will run after every three hours. The slash operator can be used with the range operator such as 1-8/2.

Also read: How to run a cron job every 5 minutes?

Schedule a cron job after every 15 minutes

There are two ways to schedule your recurring task to run after every fifteen minutes using the cron jobs.

Using the comma operator

You can specify the minutes with the gap of 15 minutes and use the comma operator in your crontab file.

10,25,40,55 * * * * <command>

The above command will schedule your job to run every hour at 10, 25, 40, 55 minutes past that hour.

Using the slash operator

You can use the slash operator to specify the step of 15 minutes to run the job after every 15 minutes.

*/15 * * * * <command>

*/15 will create a list of all the minutes and run the job after every 15 minutes. This method to specify the cron job is better and simple to understand.

You can use any of these two methods to schedule the cron job to run after 15 minutes.

Also read: How to fix ‘Sudo command not found’ error on Linux?

Chetali Shah

Chetali Shah

An avid reader and an engineering student. Love to code and read books. Always curious to learn new things :)