Can't get PHP-script running as a cronjob Can't get PHP-script running as a cronjob wordpress wordpress

Can't get PHP-script running as a cronjob


Try to run it like this:

cd /home/provadja/domains/filmhuisalkmaar.nl/public_html/wp-content/themes/filmhui‌​s-alkmaar/cron/ && php load-productions.php

Note the use of cd command at start. This means "change current working directory to ../cron/ and then run script load-productions.php".


I prefer for cron tasks to use the use the full path to included and required scripts. So, instead of:

require_once("../inc/api.php");

I generally do:

$base = dirname(dirname(__FILE__));require_once($base . "/inc/api.php");

This way the server knows exactly where to look and is not relative to certain directories.

Side note: I also like to do /path/to/php -q /path/to/script.php too. : )


I will quote fvu's comment to my question, which I have tried and can confirm now as fully working:

1) does /home/provadja/domains/filmhuisalkmaar.nl/public_html/wp-content/themes/filmhui‌​s-alkmaar/inc/api.php exist? 2) obvious error in wget usage (-O needs the name of the file in which to save the script output), try wget -O /dev/null https://www.filmhuisalkmaar.nl/wp-content/themes/filmhuis->alkmaar/cron/load-show‌​s.php

Thanks a lot everyone, for your help!