I am very new to cron jobs and I am puzzled completely. I have this cron command: set to run every hour of the day. I set it to write the output to a text file like this: $domains1 = array_map('trim', file('domains.txt')); if (!in_array($domain, $domains1)){ file_put_contents('domains.txt', "{$domain}\r\n", FILE_APPEND); } PHP: I also set it to send the output by email. I get the right output in my email but its not writing to the file. So where am I going wrong? Do I need to have: #!/usr/local/bin/php -q PHP: if so where? Thanks
Check the permissions on your domains.txt file If you have created the file as www (or some other user) it could be causing problems as Im guessing this job is running as root. For the cron to write to the file you will have to make sure the root user has write permissions. Alternatively you could try Although this will overwrite the file each time its run Hope this helps
I CHMOD the file to 777, how do I give root writing permission? yes I am using cpanel It still doesn't write to file but sends me an email with the right output
Does your file work if you manually type in yourdomain.com/cron.php Btw, the 1st 3 links in your sig file are not working (for me)
no it doesn't write to the file when I also do that. Thanks regarding my sig, I am going to get it sorted ASAP