Search code examples
phpcronmautic

How to run php command but from php script


TL;DR: I need to run a command, but only thing I can do on my hosting is visiting URL. Is there way around it?

I am trying to set up Cron on my hosting and the manual tells me:

Set up cron to run this command:

php /path/to/mautic/app/console mautic:leadlists:update --env=prod

But problem is, that my hosting (possibly from security/marketing reasons) allows running only URLs as cronjobs.

So while I can set up running php script from url:

   0 0 23 1/1 * ? * http://example.com/cronjobs.php

I cannot run actual commands as given example above.

Is there a way of workaround?

Can I somehow write "usual" php script which will emulate running the first example?


Solution

  • Here is a PHP script which allows you run Mautic commands via URL address. Description about how to use it is below the script.

    https://gist.github.com/escopecz/9a1a0b10861941a457f4