0

I am using Cron Tabs to send notifications to my android APP, but now I ran into a problem, my Host Provider has limited CronTab-s to 5, but I have 7 PHP files which I need to run in 3 separate times.

So my idea was, all that I need to run at the same time i "Group" and run them together, but I am not able to to that because PHP seems to include only the first one and then stops with that and does not include next one.

<?php 
include("push_n_lisatud.php");
include("push_n_muudetud.php");
?>

is there any workaround for that or I am on the very wrong route to achieve what I am trying to do?

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114

1 Answers1

0

Includes are not a good way to ensure several independent PHP scripts are executed. This can create a lot of problems, e.g. if one PHP script has an hard exit somewhere (e.g. die()) the next script will not be called. Same when errors occur.

A better approach would be to call them in a shell script and call the shell script from cron.

Or if you have a lot of restrictions on your webserver and are limited to PHP scripts, you can use PHP to start several other PHP scripts asynchronously with curl.

Check out this question for details on how to do that.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
  • 1
    Ty for tip, do you have any exampels for that also? never done any shells :) –  Feb 05 '18 at 11:17
  • There are many examples if you do a little research. here is one [example](https://stackoverflow.com/questions/13855666/how-to-call-php-file-from-a-shell-script-file). – Erik Kalkoken Feb 05 '18 at 11:24