Views: 8765
Last Modified: 21.09.2017
In large or medium-sized projects, sometimes there is an issue with the transfer of especially heavy agents to Cron.
- First, fully disable execution of agents on a hit. To do this, the command /bitrix/admin/php_command_line.php?lang=ru should be executed in PHP-console of Bitrxi24 product administrative menu:
COption::SetOptionString("main", "agents_use_crontab", "N");
echo COption::GetOptionString("main", "agents_use_crontab", "N");
COption::SetOptionString("main", "check_agents", "N");
echo COption::GetOptionString("main", "check_agents", "Y");
As the result, we should have NN
.
- Remove the definition of the following constants from the
/bitrix/php_interface/dbconn.php
file:
define("BX_CRONTAB_SUPPORT", true);
define("BX_CRONTAB", true);
And add:
if(!(defined("CHK_EVENT") && CHK_EVENT===true))
define("BX_CRONTAB_SUPPORT", true);
- Next, create agent verification and system messages multicasts file
/bitrix/php_interface/cron_events.php
:
<?
$_SERVER["DOCUMENT_ROOT"] = realpath(dirname(__FILE__)."/../..");
$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"];
define("NO_KEEP_STATISTIC", true);
define("NOT_CHECK_PERMISSIONS",true);
define('CHK_EVENT', true);
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
@set_time_limit(0);
@ignore_user_abort(true);
CAgent::CheckAgents();
define("BX_CRONTAB_SUPPORT", true);
define("BX_CRONTAB", true);
CEvent::CheckEvents();
?>
- And add this script into Cron:
*/5 * * * * /usr/bin/php -f /home/bitrix/www/bitrix/php_interface/cron_events.php
After that, all agents and forwarding of system Messages will be processed under cron, once each 5 minutes.
The parameter responsible for the quantity of e-mail messages, processed at once, is required to be modified to prevent the increase of e-mail messages queue. To do that, execute the following command in PHP-console:
COption::SetOptionString("main", "mail_event_bulk", "20");
echo COption::GetOptionString("main", "mail_event_bulk", "5");