Instructions to create Cron Jobs on VPS Linux - HOSTVN Blog

Create Cron Jobs on Linux VPS - Cron is one of Linux's most useful tools and a favorite tool for developers because it allows you to run automated commands at specific intervals. You can use it to automate backup tasks, clean folders, notifications, etc.

In this article HOSTVN I will show you how to create Cron Jobs on VPS Linux.

Instructions to create Cron Jobs on VPS Linux

1. Cron syntax

As with any language, working with cron is a lot easier when you understand its syntax and there are two formats you should know:

Explanation of cron syntax:

  • A: Minutes: 0 - 59
  • B: Time: 0 - 23
  • C: Date: 0 - 31
  • D: Month: 0 - 12
  • E: Day of the week: 0 - 7. Starting from Monday (number 0), and ending with number 7 representing Sunday
  • USERNAME: Replace with your username
  • / path / to / command - The command or script bash shell you want to run

In addition Cron uses 3 operator symbols that allow you to specify multiple values ​​in a field:

  1. *: Specify all possible values ​​for a field
  2. Comma ,: Specify a list of values
  3. Dash -: Specify a value range
  4. Punctuation (/): Specify a step value

Now that you know the syntax and Cron operators, let's look at some examples of cron.

2. Cron Job example

The first step to running cron commands is to install your crontab with:

Here are some examples of Cron

  • Run /root/ at 3am every day:
  • Run at 4:30 pm on the second of every month:
  • Run /scripts/phpscript.php at 10pm during the week:
  • Run Linux commands at 4:05 pm every Sunday:

3. Optional cron

  • Delete all crontab jobs.
  • Delete a user's Cron job.

4. String in Crontab

Chains are one of the favorite things for developers because they save time by eliminating repetitive writing. Cron has specific strings you can use to create commands faster:

  1. @hourly: Run once per hour (0 * * * *)
  2. @midnight: Run once daily (0 0 * * *)
  3. @daily: Same @midnight
  4. @weekly: Run once per week (0 0 * * 0)
  5. @monthly: Run once a month (0 0 1 * *)
  6. @annually: Run once per year (0 0 1 1 *)
  7. @yearly: Like @annually
  8. @reboot: Run once at each VPS / Server restart

For example, here's how to back up your system every day:


Through this article, HOSTVN introduced you to use Cron in the most basic way. If you have any comments you can leave a comment below. Also you can see more other posts here.

Nguyen Diep

My name is Nguyen Manh Cuong. I was born in a poor village in Ba Vi district, HA NOI province - windy and sunny land. Currently

Post a Comment

Previous Post Next Post

Đọc nhiều trong tuần

10 Grands Sites de modèles PowerPoint gratuit
10 Grands Sites de modèles PowerPoint gratuit

PowerPoint est toujours le roi quand il vient à un logiciel de présentation. Il a été autour depuis des siècles et chaque nouvelle version ajoute plus de fonctionnalités et rend …

17 best home jobs in 2020
17 best home jobs in 2020

Earning Money blog access_time April 13, 2020 hourglass_empty 28 least Read Finding work from home is easier thanks to high technology. Not only suitable for tho…

How much RAM is the iPhone 12 Pro?
How much RAM is the iPhone 12 Pro?

The RAM of the iPhone 12 Pro is up to 6GB.
Based on information in the latest Xcode beta from Hiraku, it can be said that both of Apple's new iPhone 12 Pro models have 6GB of R…


JavaScript is a programming language of HTML and WEB. It is lightweight and most commonly used as part of web pages, but their implementation allows Client-Side scripts to interac…