dqc2017 2014-09-09 19:35
浏览 438
已采纳

Crontab不使用cURL执行脚本

I have a cron that's set to run every ten minutes that works fine if I execute the file manually by entering

php register.php

But, my cron will not execute this file once it includes anything cURL related. My cron is as follows

*/10 * * * * /usr/bin/php /var/www/html/register.php 

I know that the cron is getting the correct file because at the very top of it, I put php's mail function to send me an email so that I know it was executed. But, anything cURL related will not execute. There aren't any global variables or server variables in the script, so that isn't the reason. I've checked both the crontab and the php error logs and nothing is there pertaining to this issue.

  • 写回答

1条回答 默认 最新

  • dongqingcheng2903 2014-09-09 20:33
    关注

    Try to add this at the beginning of your script:

    chdir(dirname(__FILE__));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何使用simulink建立一个永磁同步直线电机模型?
  • ¥30 天体光谱图的的绘制并得到星表
  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗