My Domain Host only allows 2 CRON jobs to be set. I have one already set to download a file over FTP
I need to run 10 more Cron Links from a single PHP file. Is this at all possible?
Format of Cron Link (10 Parts): https://www.example.com?route=extension/module/import&import_id=1&part=1_10
Not sure how to test this out in a single PHP file
Would something like this work?
<?php
ini_set('display_errors', 1);
$response=curl_request("https://www.example.com/?route=extension/module/import&import_id=1&part=1_10");
curl_request("https://www.example.com/?route=extension/module/import&import_id=1&part=2_10");
curl_request("https://www.example.com/?route=extension/module/import&import_id=1&part=3_10");
curl_request("https://www.example.com/?route=extension/module/import&import_id=1&part=4_10");
curl_request("https://www.example.com/?route=extension/module/import&import_id=1&part=5_10");
curl_request("https://www.example.com/?route=extension/module/import&import_id=1&part=6_10");
curl_request("https://www.example.com/?route=extension/module/import&import_id=1&part=7_10");
curl_request("https://www.example.com/?route=extension/module/import&import_id=1&part=8_10");
curl_request("https://www.example.com/?route=extension/module/import&import_id=1&part=9_10");
curl_request("https://www.example.com/?route=extension/module/import&import_id=1&part=10_10");
function curl_request($url,$method="GET",$postFields="")
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if($method=="POST")
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
}
else
{
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
}
$response = curl_exec($ch);
echo "$response";
return $response;
}
?>
Is it possible to add a time out between the links?
As I understand you want to run scripts periodically, but your web host only allows two cron jobs.
One solution is that you can run a single Php script as a cron job. Within this script, you can check the current time. If the time is correct, then you can run the other scripts. For example run the main Php script every 10 min. This script can check if it is time to run the other Php scripts.
Include all the cron files in single file and add that newly created file to cron As,
newly_created_file.php
<?php
ob_start();
require_once("filepath/filename_1.php");
require_once("filepath/filename_2.php");
require_once("filepath/filename_3.php");
require_once("filepath/filename_4.php");
?>