phpzend-frameworkzend-log

Zend_Log: How to change the log file permissions


I'm executing my script from web interface as well as a cron job. I'm using Zend_Log for logging and the log file is daily rotating (mylog_YYYY-MM-DD.log). If I execute my script from web in the day start, then my cron job is failing due to log file permission problem. I'm ok with provide 666 permissions to my log file. How can I apply the permissions using Zend_Log.

Thanks in advane. -Venkat


Solution

  • Make sure the web interface and the cron job run as the same user and you shouldn't have this issue. I guess that the website runs as one user (www, apache, etc) and your cron job runs as your specific user so whichever process ends up creating the file first makes it inaccessible to the other user.

    If you're comfortable with permissions of 666, just use the php code:

    chmod($log_file, 0666);
    

    in the code where the log file gets created.