“Cron”, did you say “Cron”?

” Cron “, vous avez dit ” Cron ” ?

Operating systems like Unix or Linux have a specific program called “Cron”.

Cron makes it easy to schedule some of your tasks. This is because it is a command that helps you run scripts or software automatically. All you have to do is indicate the desired date and time in advance.

We invite you to read the following article to discover the essentials to remember about Cron.

How did the “Cron” concept come about in the IT field?

This computer program originates from operating systems like Berkeley or AT&T. These were subsequently standardized thanks to the efforts of Paul Vixie. Initially, the goal was to have a service available every minute. And, able to examine a set of documents saved under a specific directory. The concept thus had to identify whether the shell commands could be executed during this time interval.

Cron: Where exactly does this name come from?

Cron is nothing but a diminutive of “crontab”. An association of two distinct terms “chrono” and “table”. Which thus refers to a planning table. A feature that will be essential for you to better organize yourself on a daily basis.

See also  How to Add Shopify Products Under YouTube Videos?

Indeed, it is never easy to find oneself easily in our routine tasks. The mission becomes even more complicated when these functions are numerous and varied.

A concrete example of its interest?

By way of illustration, cron is capable of playing an ogg file every morning, starting at seven o’clock, except on weekends. All under the resonances of your favorite melody for a gentle and motivating awakening. Enough to boost you to face the day with a good dose of determination on a daily basis.

How does Cron work?

Cron is categorized under the daemon family in computer parlance. This is equivalent to a program capable of operating in the background. In other words, the cron service does not run until the specified date and time have expired. It therefore migrates to a customization file, called “crond”.

At the end of each intervention, the software returns to standby mode and waits for the next event before operating again. The root account is responsible for making the program take off. This allows it to fit perfectly with your profile. However, there is an option called “kill” to automatically restart the command. A feature that is available on some Unixes.

The “crontab” command: what is it for you?

Crontab is the name given to software under Unix and Linux, favoring the programming of the customization tables of the Cron program. It is these tables which indicate the activities to be carried out, with their intervention schedule. Most ? You have the possibility to plan their periodicity. This is what earned this program its name in English ” cron job “.

See also  SEO article: how to write it for SEO?

The “crontab” command: how does it work?

The crontab command allows you to rectify your files at any time. In this regard, the software has a functionality to examine the syntax, before updating the modifications. Enough to avoid unpleasant surprises. By default, the file is stored in / var. For example: / var / spool / cron / tabs / (SuSE GNU / Linux).

Accordingly, if you are using root on a Debian-like device, the cron table will be saved in / var / spool / cron / crontabs / root. Note that most Linux systems have an additional cron table which is gathered in / etc / crontab.

For specific sub-parts of the system, like file updates, you have specific cron tables. These can be found in /etc/cron.d, /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly and /etc/cron.monthly.

Using the “crontab” command

The cron table will show you a specific command line, which is: “crontab -l”. Be careful, however, you will not be able to view the centralized table from this command. To modify the cron table, you will need to run the command: “$ crontab -e”. This will help you activate the default editor, giving access to the current table.

Table replacement and deletion

It is perfectly possible for you to replace the current table with another one of your choice, with crontab. The replacement table is accessible inside a file as a parameter: “$ crontab file-containing-the-new-table.txt”. On the other hand, to permanently delete a content from the cron table (without confirmation), you will simply have to enter the command “$ crontab -r”.

See also  Positive feedback: examples and best practices

The anacron application: perfect for tasks that do not operate 24 hours a day

Like Cron, Anacron allows tasks to be automatically triggered according to pre-programmed time periods. The difference is in their use. Indeed, Cron rather adapts to devices operating permanently, like servers. Anacron for its part, is ideal for devices operating at discontinuous frequency (Example: PCs).

More precisely, Cron runs a task at the predefined schedule (Example: October 14, 2020 at 5:45 p.m.). If the machine is not running at this precise moment, the task will not be completed even after restarting the machine. It simply evaporates. Hence all the interest of Anacron.

How does Anacron operate?

Anacron relies on relative schedule information. (Example: once a week). In other words, if you have requested a weekly task, and your computer is not running until after two weeks, Anacron will realize your delay. As a result, the application will execute the task after your machine starts up.

This application, founded by Christian Schwarz, is launched automatically each time you open Ubuntu. The software then checks if one or more tasks have not yet been completed, before executing them. It is then activated until the next boot or failing that until 7:30 am, with the initial Ubuntu settings.

Despite the fact that Anacron is more suitable for PCs, so you can use it on Ubuntu servers. The reverse, however, remains irrelevant.

Rate this article Note / 5

This article is rated at 5/5 by 2 from our readers

Leave a Comment

Your email address will not be published.