I installed SuiteCRM on my server, and I want to set up a cron job to trigger PrestaShop Newsletter Pro Module's cron job script. What should I do to set up the cron job?
Our webcron service is best for triggering SuiteCRM's cron job script. Just follow below simple steps to configure cron job for your SuiteCRM:
if (substr($sapi_type, 0, 3) != 'cli') {
sugar_die("cron.php is CLI only.");
}
to
function easycron_get_ip_address() {
if (isset($_SERVER['HTTP_X_REAL_IP']) && !empty($_SERVER['HTTP_X_REAL_IP'])) {
return $_SERVER['HTTP_X_REAL_IP'];
} else if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP'])) {
return $_SERVER['HTTP_CLIENT_IP'];
} else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
} else if (isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR'])) {
return $_SERVER['REMOTE_ADDR'];
} else {
return '';
}
}
$easycron_ip = easycron_get_ip_address();
$easycron_ip_is_from_easycron = false;
if (!empty($easycron_ip)) {
$easycron_bot_ips_in_json = file_get_contents('https://www.easycron.com/ips.json');
$easycron_bot_ips = json_decode($easycron_bot_ips_in_json, true);
if (filter_var($easycron_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
if (in_array($easycron_ip, $easycron_bot_ips['ipv4'])) {
$easycron_ip_is_from_easycron = true;
}
} else if (filter_var($easycron_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
if (in_array($easycron_ip, $easycron_bot_ips['ipv6'])) {
$easycron_ip_is_from_easycron = true;
}
}
}
if (!$easycron_ip_is_from_easycron) {
if (substr($sapi_type, 0, 3) != 'cli') {
sugar_die("cron.php is CLI only.");
}
}
Above code additionally lets webcron requests from EasyCron pass.
<?php
echo get_current_user();
2) Upload this php file to your suiteCRM server. 1 => 'xxzzyy',
to 'allowed_cron_users' =>
array (
0 => 'www-data',
),
in the "config.php" file in your suiteCRM installation (remember to replace "xxzzyy" with the real output of your get_current_user.php). So that that part of code would look like: 'allowed_cron_users' =>
array (
0 => 'www-data',
1 => 'xxzzyy',
),
Your suiteCRM cron job should be able to get triggered successfully from EasyCron now.
1 => '',
to 'allowed_cron_users' =>
array (
0 => 'www-data',
),
in the config.php file in your suiteCRM installation. So that that part of code would look like: 'allowed_cron_users' =>
array (
0 => 'www-data',
1 => '',
),