We use cookies
We use cookies to optimize our website. By continuing to browse the site, you agree to our use of cookies.
Control panel
  • Русский
  • Українська
  • English
  • UAH
  • USD
  • RUB
  • EUR
  • 0-800-307-307 Hotline
  • +38 (044) 392-74-33 Kiev
  • +38 (057) 728-39-00 Kharkiv
  • +38 (056) 794-38-31 Dnipro
  • +38 (032) 229-58-93 Lviv
  • +38 (048) 738-57-70 Odessa
  • +38(093) 170-15-42  Life
  • +38 (067) 400-88-44 Kievstar
  • +1(888)393-24-51  USA, Toll free
  • +44(131)507-01-14  Great Britain
  • +7 (499) 348-28-61 Moscow

2.11.2. Adding a cron task

Important points:

  • If the task simply specifies the path to the PHP file, it will automatically use PHP settings site in the directory of which it is located, if the path to the PHP interpreter is additionally specified - PHP settings are not used. For instance:
    • The task is listed as /home/example/example.com/sub/script.php - script script.php runs with PHP settings for sub.example.com site.
    • The task is listed as /usr/local/php72/bin/php /home/example/example.com/sub/script.php - script script.php runs without using the PHP settings of the sub.example.com site.
  • Since cron does not use the PATH variable, you need to specify the full paths to files not only when adding a task, but also in the scripts being launched.
  • If the task is triggered exclusively when the page is opened in a browser, then it should be launched by using wget.
  • The task length must not exceed 255 characters. To run long commands put them Bashscript and run it via cron.

To add a cron task, do the following:

  1. Open the section "Task Schedule (Cron)»:
  2. Click "Add task»:
  3. Specify the required settings and click "Save»:
    • «Task"- specify the command to be executed according to the schedule. It is recommended to first run it manually, by connecting via SSHto make sure it works exactly as intended.
    • «Start time"- specify the time when the task should start. Use one of the ready-made presets or specify your version. Note In the selection and verification of your option will help "Help in setting up"Which opens our cron calculator, or use third-party services like Sysmasters.net | Cron calculator or crontab guru.
    • «Comment"- if necessary, enter an arbitrary comment to the task. Used for convenience. Comments can be useful when there are a lot of added tasks.
    • «Send report about by e-mail"- if you want to receive cron task execution reports to the mail, specify the mailbox to which you want to send them, if the reports are not needed - leave the field blank.
  4. Wait approximately 30-60 minutes for the changes to take effect.

To specify when to start Cron tasks, a specific syntax is used for each value of the specified time. Syntax elements can be combined with each other by separating them with a comma, for example: */30, 1-10, 53 - the task will be launched at: 00, 01 and all numbers up to 10, 30, 53.

  • */X - launching the task at a time multiple of the specified in X. For example, an indication */20 for seconds and minutes will run the task in the following values: 00, 20, 40.
  • 1,2,3 - listing the required values separated by commas.
  • 1-10 - an indication of the interval of the required values, in the example all numbers from 1 to 10 will be used.
  • * - any value.

All added tasks are displayed in the list:

  • «Start time"- the task launch schedule in the standard cron format.
  • «Next launch"- date and time of the next scheduled task execution. Attention! The launch at the specified time may not take place if less than 30-60 minutes have passed since the task was added or changed.
  • «Task"- the full text of the command, a comment to the task and the launch schedule in a human-readable form.
  • «Report"- the mail address where the task progress reports, or a dash.
  • «Control»- task control buttons:
    • «Suspend task execution" or "Restore task execution"- stop or resume the launch of a scheduled task.
    • «Test run of the task"- start the task manually. It can be used to check the work of a command or launch it ahead of schedule before the scheduled time. After launch, the window displays the contents of standard output - the text displayed by the command during its execution, or information about errors.
    • «Edit"- change task settings.
    • «Delete"- deleting the task.

Note

The video shows the old form of adding a task, but the general principles of cron operation have remained unchanged.