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 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥30 CanMv K210开发板实现功能
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile