Cronjob saves json into a wrong directory [duplicate]
By default Cron jobs are executed in the user's home directory. While in your script is not provided path where the output file to be saved, it will be saved into the directory where the script is executed.
According to the question, you want to generate the .json
file into the same directory where the script is located. So (in this case) you have to change your code in some way, similar as this:
$parseinfo = 'parseme.json';
$path = realpath(dirname(__FILE__));
$handle = fopen("$path/" . $parseinfo, 'w');
fwrite($handle, json_encode($res));
If you don't want to change the script you could change the Cron job in this way:
*/10 * * * * root cd /var/www/somederictory/somefolder/ && php parse.php > /dev/null