Cron

Contents...

Some applications may require that certain actions are automatically executed by schedule.

In UNIX-like operating systems such actions are managed by the cron daemon.

Periodically executed actions are described by means of special instructions added to crontab configuration files. Each instruction must contain a specially formatted description and the command to be executed as shown below:

* * * * * executed command
- - - - -
| | | | |
| | | | ----- Day of the week (0 - 7) (Sunday = 0 or 7)
| | | ------- Month (1 - 12)
| | --------- Date (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

Examples of cron job descriptions

# Executed every 10 minutes
*/10 * * * * $HOME/bin/every10min

# Executed every day at 06:30
30 6 * * * $HOME/bin/daily
  
# Executed each hour on working days
0 * * * 1-5 $HOME/bin/hourly

# Executed at 01:00 from Saturday to Sunday
0 1 * * 7 $HOME/bin/weekly

Read more about cron and its configuration in an article in Wikipedia.

Setting up a cron job in the cPanel

cPanel offers a user-friendly web interface for cron job management.

To add a new job, follow the steps listed below.

  1. In the main cPanel screen click on "Cron jobs" in section "Advanced":

  2. On the next page complete the "Add New Cron Job" form:

    The picture shows adding a job to be executed every 10 minutes.

    After the form has beem completed, click on "Add New Cron Job" button.

  3. The newly added job will appear in the job list at the page bottom: