问题与php命令行 [英] issues with php command line

查看:163
本文介绍了问题与php命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网络服务器上创建了一个cron作业。该cron每几个小时运行一个PHP文件。它是缓存创建技术。但是有一个问题 - 我的cron命令看起来像这样: php -q /folder/phpfile.php 。当我直接从我的浏览器运行phpfile.php,一切都好,但当CRON运行该文件,它总是输出头已发送错误到error_log!提到的php文件DO开始于 if(!isset($ _ SESSION))session_start(); 但是error_log显示正确的session_start

I have created a cron job at my webserver. That cron runs a php file every few hours. It's cache creating technique. But there's a problem - my cron command looks like this: php -q /folder/phpfile.php . When i run "phpfile.php" directly from my browser, everything is ok, but when CRON runs that file, it ALWAYS outputs "headers already sent" error to "error_log"! Mentioned php file DO begins with if(!isset($_SESSION)) session_start(); but "error_log" show that exactly "session_start()" line is throwing the warning!

有什么问题?当我使用浏览器运行该文件时,为什么一切正常,但是当cron这样做时,生成了已经发送的头文件?

What's wrong? Why is everything ok when i run that file with browser, but when cron does it, "headers already sent" is generated?

推荐答案

>

output_buffering directive is apperantly ON in your web-server and turned off in cli-php and it is right thing. Because no one wants to wait for content till script ends a job. We want to see what is happening when script is running.

错误的是你用cli脚本发送头。会话不是真正需要在终端,是吗?

Wrong thing is that you send header with a cli script. Session is not really need in terminal, is it?

这篇关于问题与php命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆