file_put_contents在cron作业中无法正常工作

时间:2013-10-09 09:36:54

标签: php mysql cron

我有一个运行每1分钟的cron作业向手机发送推送消息。

1.我在数据库中执行获取查询以获取我需要发送的所有消息

2.使用该数组中的数据,我执行另一个获取查询。 我使用file_put_contents将数据写入某个文件

3.然后我使用某些服务发送推送消息。

邮件已成功收到,但数据未写入文件(我在第二点开始)。

注意:当我在本地计算机上手动运行此文件时,此代码运行良好。

我找到了什么

有人建议我你的mysql执行查询速度慢,所以之前执行其他行脚本,所以错误。

守则

    Sone database query that will give customer ids in $customer_ids array

    $customer_ids = array_unique($customer_ids);
    foreach ($customer_ids as $customer_id){
        //Problem is here.file is written here using file_put_contents (this does not work-file does not update)
        PushMessage_Model_Mapper_PushMessage::getPublishfile($customer_id);
    }
    foreach ($customer_ids as $customer_id){
        //push messages are send by calling some function
    }

此类行为是否存在任何已知问题。

1 个答案:

答案 0 :(得分:2)

验证执行crontab的用户是否可以写入该文件。

相关问题