0

我花了几个小时来搜索使用 php 执行 cron 的信息,但对我没有任何用处……我想每 30 分钟后执行一次我的 php 脚本……这是 myscript.php

<?php
date_default_timezone_set("Asia/Calcutta");
$datetime=date("Y-m-d G.i:s", time());
file_put_contents("aaaaa.txt", "The current time is: $datetime\r\n", FILE_APPEND);
?> 

我用来执行 cron 命令的脚本...是 crontest.php

</php
$abc=array();
$dir=dirname(__FILE__);
echo exec("'*/30 * * * * /bin/usr/php $dir/myscript.php' 2>&1", &$abc); 
echo $output;
?>

我尝试了许多不同的命令......比如......

"'crontab -l */30 * * * * /bin/usr/php $dir/myscript.php' 2>&1"
"'crontab -l */30 * * * * php myscript.php' 2>&1"

但没有什么能妨碍我..我不明白我还能做什么..请有人帮忙,请在执行 crontest.php 我收到错误“sh:*/30 * * * * /bin/usr/php /home /content/71/9988871/html/examples/myscript.php:没有这样的文件或目录”

4

1 回答 1

0

尝试按照以下步骤在终端中设置 cron 作业:

1) 打开终端

2) 运行命令

crontab -e

3)最后添加以下内容

*/30 * * * * /usr/bin/php /path of cron file

这将每 30 分钟自动运行一次 cron 文件。

于 2013-11-13T10:03:19.603 回答