2013-10-10 15:37
浏览 34


I'm trying to debug a PHP application that is running from the command line. I want to use a cronjob later on to invoke the module every hour.

For debugging I execute the PHP script like this:

php -c /etc/php5/apache2/php.ini /var/www/module/test/autostart/start.php 12 &

(forget about the „12“ - it's a parameter for the script)

Now basically I get this output via SSH:

[2] 10181
[1] Done                php -c /etc/php5/apache2/php.ini /var/www/module/test/autostart/start.php 12 

I have no idea what I have changed but a few weeks ago I got the actual php errors directly on the screen. That's what I expect. But I don't know how to force PHP to output me the result directly.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dongmu5246
    dongmu5246 2013-10-10 15:57

    When you use & at the end, command is started in background. You can see background processes by command jobs. When you try it, you can see php process in 'stopped' state.

    Problem is that php is waiting for input. It is caused by this php extension:

    readline php extension

    Run it this way:

    php -c /etc/php5/apache2/php.ini /var/www/module/test/autostart/start.php 12 < /dev/null &

    or disable that extension.

    点赞 评论
  • douxun7992
    douxun7992 2013-10-10 15:39

    drop the ampersand from the end of the commandline. it tells the shell to run the command in the background.

    edit: otherwise, it could be because you're using the web-tuned php.ini: i would expect that configuration to log errors into a logfile.

    点赞 评论
  • doujiang5211
    doujiang5211 2013-10-10 15:42

    You won't see any output because you are running the script with an "&", you fg command to bring back the process to the foreground.

    点赞 评论