How to Use Cron in Linux

This is the first article in the Linux Command tutorial serious. 

In this article, we will talk about the basic usages of Cron and some of the commands which are used to manage cron. 

Get 50$ Credit on Vulture Clouds Here and Test the Instruction for free.

Cron Daemon main function in Linux is running the Scheduled tasks. 

In this way, you can automate a lot of your micro tasks without remembering and doing them. 

For example, People in the hosting company will regularly schedule their user files. 

They are maintaining many systems and they can’t do some basic tasks everyday manually. 

For that, they can setup a cron job and let the system do the task repeatably. 

They have to only check the error log after sometime.

Let us say you have an Ubuntu VPS and running a site on it. 

You may use Lets encrypt SSL. Lets encrypt is a free SSL.

It expires every 90 days and you have to renew it. 

Now you might be seeing security warning message in chrome browser, when you visit a site which does not have SSL.

Since it is a long duration for a job, you can’t remember it to renew the SSL. 

So, when the SSL expires, chrome will start showing warning message to your visitors. 

Eventually, you will lose visitor for sometime even if your site is safe for the visitors. 

In order to avoid this ugly situation, you can schedule a cron job to do this task. 

I will explain that one in upcoming article. 

Opening Cron Tab in Linux

You can use the below command to open the cron tab to schedule a task. 

$ crontab -e

The Cron tab command will follow the syntax. 

[Minute] [hour] [Day_of_the_Month] [Month_of_the_Year] [Day_of_the_Week] [command]

This is the range for Cron Tab fields mentioned above. 

Field    Description    Allowed Value
MIN Minute field 0 to 59
HOUR Hour field 0 to 23
DOM Day of Month 1-31
MON Month field 1-12
DOW Day Of Week 0-6
CMD Command Any command to be executed.

Refer the above video to learn more about crontab in linux. 

If you want to schedule cron in different time and dates. 

Here is the site which will help you create the perfect syntax for cronjob


Share on facebook
Share on twitter
Share on linkedin

Leave a Comment