dongshanyan0322 2009-08-14 01:58
浏览 77
已采纳

有人可以向我解释cron作业脚本的局限性吗?

I think I'm confused about exactly what the difference is between running a PHP script as a cron job versus accessing it with a browser. When I test test.php by hitting it with Safari, it writes to a text file as expected, makes DB entries, etc. When it runs as a cron job, it does everything except write to a text file.

I already dealt with it not heading to the PHP parser by inserting: #!/usr/bin/php at the start of the file.

Why won't my script write to my text file via cron, when it works via Safari?

(It's a straight forward fopen, fwrite, fclose bit of code, so revealing it wouldn't be illuminating I don't think)

  • 写回答

2条回答 默认 最新

  • doujiejujixi27244 2009-08-14 02:01
    关注

    it will be the user permissions. while the apache (or whatever webserver you are using) may have permission to write to that folder, cron user does not if you make them both members of the same group or make the folder world writable that should solve your problem

    keep in mind world writable is not a good security measure

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大