cron - php does not create a file when executed with cronjob -


i have simple php file, creates text document everytime 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 run file using browser txt file created on server. when run file cronjob, not create txt file. when go private > cron.log on server see cronjob works fine , result printed cron.log.

can tell me why? need write file on server :)

when executed in cronjob, need provide full path. script noch executed in directory it's located in , therefor relativ paths won't work.

$absolut_path = "whatever absolutpath is"; // maybe /var/www/html/ $log_name = $absolut_path."cronjob". $date; 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -