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 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)