How to run cron jobs every 5, 10, 15 or 30 minutes?

Better Stack Team
Updated on October 5, 2023

Every minute cron goes through all the crontabs and looks for the jobs that should be executed. The exact time of the execution can be specified using the cron syntax. Whenever the parameter matches the current date and time cron job is executed.

🔭 Want to get alerted when your Cron doesn’t run correctly?

Go to Better Stack and start monitoring in 5 minutes.

 
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  *  command to be executed
*  *  *  *  *  echo 'Hello world!'

You can use certain operators to specify the time:

  • * is used as any value
  • - is used to state the range of values (e.g. 1 - 5)
  • , is used to specify multiple values
  • / is used to specify step values that can be used in conjunction with ranges (e.g. 1-10/2 is the same as 1,3,5,7,9)

Every 5 minutes

 
*/5  * * * * echo 'Hello world!'

Every 10 minutes

 
*/10  * * * * echo 'Hello world!'

Every 15 minutes

 
*/15  * * * * echo 'Hello world!'

Every 30 minutes

 
*/30  * * * * echo 'Hello world!'

Using the */n you can specify the time of the jobs that will be executed every n minutes.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github