duangu4943 2016-09-14 21:48
浏览 33

使用cronjob创建多个JSON文件(PHP文件)

Quite important, I don't really know how to write PHP, but I have some experience with JavaScript.

I created a PHP file which scrapes a website and writes the data to different (22) JSON files. If I visit the file from my browser the script does what it supposed to do and it creates the 22 JSON files.

Nou I wanted to use the cronjob functionality to run the script daily. I tried it and I received a mail with the echo's I normally would see in my browser, so I could say the script runs. The script has to run to post the echo's. But there are no JSON-files created.

Why doesn't my script create the files when I run it via a cronjob?

I'm using this function to write the files:

function write_to_file($value,$content) {
    echo "Done<br>";
    $file = fopen($value.".json","w");
    fwrite($file,$content);
    fclose($file);
}
  • 写回答

1条回答 默认 最新

  • doucha4054 2016-09-14 22:21
    关注

    As Barmar suggested, the files are in my home directory. Thanks!

    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动