dpkt17803 2016-08-04 21:35
浏览 64
已采纳

php exec()Linux服务器奇怪的输出

I am attempting to backround a php script since it will take more than a minute to complete and I do not want the user to wait.

my exec command is as follows:

exec ('php -f path/to/file.php > path/to/output.log 2>&1 &');

first of all the script in the file didnt do what i programmed it to do however, the output file still recieves this output:

X-Powered-By: PHP/5.6.24
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Content-Type: text/html; charset=UTF-8
Link: <https://example.com/wp-json/>;
rel="https://api.w.org/"
Link: <https://example.com/?p=687>; rel=shortlink
....

This output is not at all what my script is supposed to make, it makes no sense to me.

the rest of the output is a html document with differnet links to my website and such.

can anyone clue me into why this is happening and not simply running the script?

BTW

I have used different commands like /usr/bin/php with the same affect

UPDATE

I noticed that after changing the first path/to/file.php paremeter to gibberish i.e.

exec ('php -f asdfjaskldfj > path/to/output.log 2>&1 &');

that the output remains the same, not sure what this means but i believe it to be noteworthy

  • 写回答

1条回答 默认 最新

  • dongluolie3487 2016-08-05 07:40
    关注

    After must trial and error I found that

    usr/bin/php 
    

    pointed to a php command that only outputted documentation on my current server, and when I changed it to

    usr/bin/php5 
    

    it worked. Very hard to find documentation on the linux php command, and I still have yet to find anyone else with the same problem, but it has been resolved nonetheless.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题2
  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备