通过cronjob执行PHP脚本 - 脚本中未读取/ var / www / html /目录中数据目录的路径

Here is a PHP script:

<?php 
$pathToDirectory = "/var/www/html/Tests/Workspace/data";
echo "pathToDirectory: " . $pathToDirectory . "
";
?>

In my Ubuntu 16.04 OS, I am trying to execute this script every minute as a part of a cronjob. I have added the cronjob like so to my root's crontab file:

* * * * * /var/www/html/Tests/Workspace/phpScript.php >/var/www/html/Tests/Workspace/logs/cronScriptOutput.out

And the cronjob runs successfully. The problem is that once the cronjob has run, following are the contents of the cronScriptOutput.out file.

pathToDataDirectory:

And that's it. That actual path string is NOT printed.

The question is why? How do I fix this.

This might not seem serious here, but the problem is that I need to read a file from that path and go further from there. So I need this fixed. I need that path to be read in my PHP script.

May be you need add php before script name?

* * * * * php /var/www/html/Tests/Workspace/phpScript.php >/var/www/html/Tests/Workspace/logs/cronScriptOutput.out 

Of course, better use full path to php - /usr/bin/php - or what you have