dongshanyan0322 2009-08-13 17: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-13 18: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条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部