简体   繁体   English

Cron Job无法通过PHP脚本运行

[英]Cron Job not running via PHP Script

Firstly, I have built PHP scripts that run as a cron job when I set it up in linux and it works fine. 首先,我构建了PHP脚本,当我在linux中设置它时,它可以作为cron作业运行,并且运行良好。

What I am doing in the script is writing to a file which isn't being done but works fine via CURL in terminal. 我在脚本中所做的事情是写入未完成的文件,但可以通过终端中的CURL正常工作。

example (the first thing that happens in the script) : 示例(脚本中发生的第一件事):

#!/usr/bin/php
<?php
$fp2 = fopen('FeedLog.csv', 'w');

fputcsv($fp2,array("Started Cron",date("F j, Y, g:i a"),0));

I feel like there is some sort of permission issue? 我感觉是否存在某种许可问题? I have set both the script and the file its writing to, to 777. 我将脚本及其写入的文件都设置为777。

There are no errors or anything in logs nor output. 日志中没有错误或任何内容,也没有输出。

Either try a absolute path to the file in fopen, or use chdir to change to the correct directory. 在fopen中尝试文件的绝对路径,或使用chdir更改到正确的目录。

#!/usr/bin/php
<?php
chdir('/home/user/');
$fp2 = fopen('FeedLog.csv', 'w');
fputcsv($fp2,array("Started Cron",date("F j, Y, g:i a"),0));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM