开发者

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.

What I am doing in the script is writing to a file which isn't being done but works fine via CURL in terminal.

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.

There are no errors or anything in logs nor outpu开发者_如何学Pythont.


Either try a absolute path to the file in fopen, or use chdir to change to the correct directory.

#!/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));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜