Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Run Cron Job Every 5, 10 or 15 Minutes - DesignLinux

Sep 21 2020
designlinux 0 Comments
How to Run Cron Jobs Every 5, 10 or 15 Minutes

In Linux, a cron job means a task that should execute at defined intervals. You can set interval of a minute, hour, day of the week, month, day of the month, or in any combination of these units. In this tutorial we will show you how to run cron job in Linux system.

The Cron jobs are mostly used to do automatic task like backing up data or databases, update the system with latest security patches, sending emails, monitor system and more. Commonly, cron job runs at every 5, 10, or 15 minutes intervals.

Crontab Syntax#

Crontab is a text file that contains the schedule of the cron jobs. You can create, view, modify or delete with crontab command.

In the crontab tab file you should defined separate line for each cron. Each line contains six fields separated by a space followed by the command to be run:

* * * * * command(s)
^ ^ ^ ^ ^
| | | | |     allowed values
| | | | |     -------
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

You can define following operators for first five fields (time and date):

  • * – The asterisk operator means, it allowed all values. So if the asterisk symbol in the Minute field then it will perform at each minute.
  • - – You can specify a range of values using the hyphen operator. For example, if set 2-4 in the Day of the week field then task will be run on every Tuesday to Thursday.
  • , – The comma operator allows you to define a list of values for repetition. If you have set 2,3,6 in the Hour field then the task will run at 2 am, 3 am and 6 am.
  • / – To set step value you can use the slash operator allows you to specify step values that can be used in conjunction with ranges. For instance, if you set 1-20/3 in the Minutes field the action will be performed every two minutes in range 1-20, same as specifying 1,3,5,7,9. You also can use the asterisk operator to specify a job to run at every 20 minutes like “*/20”.

Create / Modify crontab file#

If the crontab file not exists or want to modify then you can use crontab -e command.

Run a Cron Job Every 5 Minutes#

To run cron job at every five minutes you should use the step operator and add the following line to crontab file:

*/5 * * * * command

Here, */5 means create a list of all minutes and run the job for every fifth value from the list.

You also can run cron job at every five minutes using comma operator by creating list of minutes:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * command

The first method is easy to use and recommended.

Run a Cron Job Every 10 Minutes#

Append the following line to run cron job at every 10 minutes interval:

*/10 * * * * command

Run a Cron Job Every 15 Minutes#

Add the following line to run cron job at every 15 minutes interval:

*/15 * * * * command

Conclusion#

In this guide you learned how to run a cron job at every 5, 10 and 15 minutes interval.

If you have any question, feel free to leave a comment below.

Related

Tags: cron, crontab, terminal

How to Install Moodle Learning Platform with Nginx in CentOS 8

Prev Post

How to Fix ERROR 1130 (HY000): Host is not allowed to connect to this MySQL server

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 847
  • 615,219

DesignLinux.com © All rights reserved

Go to mobile version