dsxay48646 2018-12-04 20:15
浏览 48

如何让我的cron工作在cpanel中工作?

I need to automate a couple things for my website, one of them being having the database cleared at midnight every night. I looked at cron job tutorials and came up with a script

<?php 
$con = mysqli_connect("localhost", "root", "password", "test");
$sql = "DELETE FROM markers";
$con->exec($sql);
echo "Record deleted successfully";
$con = null;

INSERT INTO `markers` (`name`, `lat`, `lng`, `id`, `questTitle`, `questReward`, `category`, `date_submitted`) VALUES ('Marker1', 41.2952, -92.644, 1, NULL, NULL, NULL, NULL);

this just wipes the database and re-inserts records with empty values to be modified throughout the day.

I tried setting up a cron job to run this at midnight using cpanel, my path is

/usr/bin/php /home/user/public_html/command.php

I have the command.php in my uploaded web files and set the job to run every 30 mins to test it, but no matter what I do I cannot seem to get it to work. Any help to resolve the issue would be appreciated, thank you

  • 写回答

1条回答 默认 最新

  • douliang2167 2018-12-05 03:43
    关注

    What i noticed is that you are using

    /usr/bin/php /home/user/public_html/command.php

    Have you tried just using the plain php command only?

    30 * * * * php /path/to/php/file >> /path/to/desired/log/file/location

    My assumption is that the php is not installed on usr/bin directory.

    Hope this helps

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测