I have a very simple php file, that creates a text document everytime it runs:
$date = date('Y-m-d H-i-s', time());
$log_name = "Cronjob". $date;
if($fh = fopen($log_name,'w')){
fwrite($fh, print_r($date));
fclose($fh);
}
When I run the file using my browser a txt file is created on my server. When I run the file with a cronjob, it does NOT create a txt file. When I go to private > cron.log on my server I see that the cronjob works fine and the result is printed into the cron.log.
Can someone tell me why? I need to write that file on the server :)
$log_name? It was created but it could be somewhere. So, it is better to use full path to see if the file is created.