繁体   English   中英

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

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

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

我到处都在Google和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 ~/

在那里,我的档案。

暂无
暂无

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

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