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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵