Cron Job Scheduler

The cron job scheduler can be configured in the server control panel:

Setting up Cron jobs in ISPmanager

Configuring Cron Jobs in VestaCP

Also, you can configure scheduled tasks via SSH.

To view existing cron jobs, enter the command:

crontab –l

To edit the list of tasks, open the cron editor with the following command:

crontab –e

An editor will open in which you can specify the necessary tasks.

cron-job-scheduler_20221025_223712_1

Each task starts on a new line. First, the frequency of launch is indicated, and then the task itself.

At the end of the last command entered, press Enter to linefeed and save the changes:

  • F2 - save changes,
  • F10 - exit the editor (you will need to confirm or discard changes).

If all the data in the editor was entered correctly, the terminal will display the following output:

crontab: installing new crontab

Frequency of the assignment

To indicate the frequency of the task, the following five fields are used, located on the left side of the task line:

  • minutes (from 0 to 59),
  • hours: (from 0 to 23),
  • days (from 0 to 31),
  • months (from 0 to 12),
  • days of the week: (from 0 to 6, 0 - Sunday).

* - any parameter value is applicable.

1,2,4 - execution of the task during the specified periods,

1-4 - execution of the task in the periods in this interval.

Let's give an example of setting the frequency of tasks execution using the example of days of the month:

  • * - everyday;
  • */n - every n days;
  • n - with the beginning of the n-th day;
  • a, b, c - with the beginning of the specified days.

Examples of the frequency of tasks execution for all time parameters:

  • 0/40 * * * * - every 40 minutes;
  • 0 9.17 * * 2 - at 9 and 17 hours every Monday;
  • 0 12 18 * * - at 12 noon on the 18th day of each month;
  • 0 */4 * * 3 - every 4 hours on Tuesdays;
  • 0 5 * * 2 - every Monday at 5:00.

Bug tracking

For diagnostics of executed scripts, it is recommended to enable sending errors to the administrator's email (specified in the MAILTO line when connecting via SSH).

Notes on working with cron

1. To select the PHP version when starting the script, specify the path to the interpreter:

/opt/phpXX/bin/php,

where XX is the required version, can be specified with or without a point (XX or X.X).

For example, to run script.php from PHP 5.6, enter:

/opt/php56/bin/php /home/u/user/website_directory/public_html/script.php

user – login,

u - first letter of login.

2.  Running a script that requires web server variables directly through the PHP interpreter can lead to errors.

If you have any questions, please create a ticket to technical support.