0

I am running a LMS (Learning Management System) online, and it requires running a file named 'training/admin/cli/cron.php' every minute. The problem is my host only allows for a cron job to be ran every 30 minutes.

I tried to create a file named cron_script.php with the following and set it to run every 30 minutes:

<?php

set_time_limit(0);
$turns=0;

while($turns < 30) {
    exec('training/admin/cli/cron.php');
    sleep(60);
    $turns++;
}

?>

However it only seems to run once. I am not even sure how to troubleshoot the error message as I can't print anywhere since it is being ran by cron.

Dharman
  • 30,962
  • 25
  • 85
  • 135
user2860417
  • 103
  • 1
  • 1
  • 6
  • You should probably use the full path + php executable: `exec('/usr/bin/php /my/folder/training/admin/cli/cron.php');` – 0stone0 Apr 18 '23 at 14:52
  • Does this answer your question? [Execute a PHP script from another PHP script](https://stackoverflow.com/questions/8450696/execute-a-php-script-from-another-php-script) – 0stone0 Apr 18 '23 at 14:52
  • hi, Please find [Link](https://stackoverflow.com/questions/18737407/how-to-create-cron-job-using-php) to similar question asked previously in SO. .... In addition to it ... note that you can [generate log files](https://stackoverflow.com/questions/3069624/running-a-php-script-via-cron-how-can-i-log-any-output) for the cron at the time of setup .... – Anant V Apr 18 '23 at 14:55

1 Answers1

0

It's possible. Because default running time limit is 30 seconds. Use this function https://www.php.net/manual/en/function.set-time-limit.php or modify php.ini file "max_execution_time" value.