我有一个每 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
}
此类行为是否存在任何已知问题。
验证执行 cronjob 的用户是否可以写入文件。