cronlocalhostsilverstripemamp-pro

Silverstripe 4.11 access dev/tasks with cronjob on localhost


Online with my provider i have setup a cronjob to execute a Silverstripe dev/tasks/MyTask to send an email to a recipient every day.

The working cronjob online:

30 6 * * 1-7 /usr/bin/php56-cli /var/home/mysite/framework/cli-script.php dev/tasks/MyTask > /dev/null 2>&1

On macOS i run MAMP PRO 5.7 and i access all my web-stuff with http://localhost/mysite.....

now i try to get the cronjob working on localhost without success.

in terminal i do:

crontab -e
* * * * * /Applications/MAMP/bin/php/php7.4.2/bin/php http://localhost/mysite/dev/tasks/MyTask  > /dev/null 2>&1

and i have given full disc access within System Preferences / Security & Privacy to /usr/sbin/cron.

I get a Cron Daemon email telling me:

Could not open input file: http://localhost/mysite/dev/tasks/MyTask

(The task is working if run through the browser directly.)

What am i missing?

Update:

after following this:

https://www.taniarascia.com/how-to-set-up-a-cron-job-in-mamp/

and this:

https://www.taniarascia.com/setting-up-a-basic-cron-job-in-linux/

i closly was looking at the working online cronjob. for working with Mamp on localhost we need to have the Mamp-part to point to php:

/Applications/MAMP/bin/php/php7.4.2/bin/php

and to the cli-script.php for Silverstripe located in:

/Applications/MAMP/htdocs/mysite/vendor/silverstripe/framework/cli-script.php

and to:

dev/tasks/MyTask

all in all the working solution is:

* * * * * /Applications/MAMP/bin/php/php7.4.2/bin/php /Applications/MAMP/htdocs/mysite/vendor/silverstripe/framework/cli-script.php  dev/tasks/myTask  > /dev/null 2>&1

Solution

  • after following this:

    https://www.taniarascia.com/how-to-set-up-a-cron-job-in-mamp/

    and this:

    https://www.taniarascia.com/setting-up-a-basic-cron-job-in-linux/

    i closly was looking at the working online cronjob. for working with Mamp on localhost we need to have the Mamp-part to point to php:

    /Applications/MAMP/bin/php/php7.4.2/bin/php
    

    and to the cli-script.php for Silverstripe located in:

    /Applications/MAMP/htdocs/mysite/vendor/silverstripe/framework/cli-script.php and to:

    dev/tasks/MyTask
    

    all in all the working solution is:

    * * * * * /Applications/MAMP/bin/php/php7.4.2/bin/php /Applications/MAMP/htdocs/mysite/vendor/silverstripe/framework/cli-script.php  dev/tasks/myTask  > /dev/null 2>&1