Understanding CRON to Run Automated Tasks

One of the widely used utilities of Linux is Cron, which enables users to automate execution of tasks. Cron allows setting up schedules of certain tasks to run at specific times or at specified frequencies. At the scheduled time/dates, tasks are automatically triggered without a user intervention.

Technically, Cron is a daemon that stays resident in memory after getting started once. This is how Cron keeps track of date/time to run specified commands or to invoke specified scripts/applications at their scheduled times. The schedule for running tasks is defined in the configuration files called, crontab. The crond application (the Cron daemon) keeps invoking commands as defined in the crontab files.

You can set up the schedules in the crontab files defining configuration details, such as:

SHELL – the UNIX shell Cron is supposed to run under.

PATH – It is the path to directory (or directories) where the Cron application actually resides.

MAILTO – It is the e-mail address of the recipient of the output of running the Cron jobs.

HOME – It is the Linux home for the Cron daemon.

In addition, date, time, and frequencies for running various tasks are defined in the crontab files against few specific fields. Values for these fields specify the following values related to running the tasks:

Minute – Minute of the hour and can take a value between 0 and 59

Hour – Hour of the day and can take value between 0 and 24

Dom – Date of the month and can take a value between 0 and 30

Month – Month of the year and can either take a value between 0 and 12 or the name of month

Dow– Day of the week and can either take a value between 0 and 7 or the name of day

User– Name of the user required for running the scheduled job

Cmd – Command that needs to run at the specified schedule

These details are required to configure the tasks to run at specific date/times and frequencies with the help of the Cron utility of Linux.