Cron作业不能在XAMPP Mac OS X上运行,但可以正常工作


Cron job not running on XAMPP Mac OS X but works otherwise

我试图在Mac上使用XAMPP运行cron作业。我尝试了以下命令,但根本没有创建文件。如果我手动运行它,使用localhost/writer/writer.php,它可以工作。

我找遍了谷歌和SO,但没有一个解决或共鸣我的问题。任何帮助都是感激的。

尝试的命令:

* * * * * /Applications/XAMPP/xamppfiles/bin/php /Applications/XAMPP/xamppfiles/htdocs/writer/writer.php
* * * * * php /Applications/XAMPP/xamppfiles/htdocs/writer/writer.php

为测试目的而运行的代码

<?php
$file = 'people.txt';
// Append a new person to the file
$current = "John Smith'n";
// Write the contents back to the file
file_put_contents($file, $current);
?>

注意,我也试过在XAMPP之外运行一个示例cron,通过这样做:(它工作了)。

* * * * * echo 'test' > /Desktop/test.txt

同样,如果我在目录中,我选择"php writer.php",它也可以工作。

我找到了解决方案。我真是太蠢了,是的,蠢到极点了。

文件在根目录下输出,为了验证,我检查了cd ~/

在那里,我的文件。

相关文章: