I've updated my crontab using crontab -e
to run the Laravel task scheduler every minute. It wasn't working so I set it to add its output to a log file, like so:
* * * * * php /path/to/project/artisan schedule:run >> cron_output.log
Now the log contains the following message:
Parse error: parse error in /path/to/project/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233
This is the method it points to (I've commented next to line 233):
function cache()
{
$arguments = func_get_args();
if (empty($arguments)) {
return app('cache');
}
if (is_string($arguments[0])) {
return app('cache')->get($arguments[0], $arguments[1] ?? null); //line 233
}
if (! is_array($arguments[0])) {
throw new Exception(
'When setting a value in the cache, you must pass an array of key / value pairs.'
);
}
if (! isset($arguments[1])) {
throw new Exception(
'You must specify an expiration time when setting a value in the cache.'
);
}
return app('cache')->put(key($arguments[0]), reset($arguments[0]), $arguments[1]);
}
I don't understand this issue, as Laravel runs normally otherwise. PHP version is 7.2 (based on php -v
and also phpinfo()
) so that shouldn't be a problem. Is it possible that somehow the crontab is using an older version of PHP? If so how do I fix this? Any other ideas?