dongzhanlu8890 2017-07-26 20:26 采纳率: 0%
浏览 67
已采纳

在CPanel上设置Cron作业以执行PHP脚本

As implied in the title, the Cron Job is supposed to execute a php file (update.php, to be specific). The php file then writes to a csv file stored in the same directory.

I have the time set to * * * * * so that it executes every minute. The command is written as follows: php -q /home//public_html/wallboard/update.php I don't believe this is causing any errors, though it also doesn't seem to write to the CSV file. When I visit update.php in a browser, however, it executes and writes to the CSV file immediately. I'm not experienced with Cron Jobs and I'm sure there's an issue, but I don't know what exactly that issue is. Let me know if you have suggestions/questions. Any help is appreciated!

Current Command:

* * * * * usr/bin/php -q /home/<user>/public_html/wallboard/update.php

update.php:

<?php

include('lib/HelpDeskView.php');
include('lib/WallboardDisplay.php');
include('helpdesk.csv');
$helpdesk = new HelpDeskView();
$text="
test,test,test";
file_put_contents( "helpdesk.csv" , $text, FILE_APPEND);
  • 写回答

4条回答 默认 最新

  • doutang7415 2017-07-27 20:14
    关注

    Since your script resides in your public_html directory you can use wget for your Cron Job

    wget -O - -q https://yoursite.com/wallboard/update.php
    

    -O - output is written to the standard output in this case it will go to the email address you specify in CPanel

    -q quiet mode

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?