我有一个函数,我想通过cron执行。如果我只是点击网址www.example.com/TestProjects/codeigniter/controller/function
这个函数执行得很好,如果我把它放在cron上不起作用。
我尝试将其设置为
public_html/TestProjects/codeigniter/controller/function
而这通过这样的错误消息
public_html/TestProjects/codeigniter/controller/function: Not a directory
谁能帮我如何在 cron 上设置它?
** hi dude try this **
卷曲 http://nztdemo.com/TestProjects/ERP/cron/index
首先尝试在 CLI 模式下运行该控制器方法。在控制台中,转到项目目录,然后在 CLI 模式下运行脚本:
cd TestProjests/codeigniter
php index.php controller function
如果这有效,请在 crontab 中插入相同的行,但使用绝对路径:
php /path_to_your_projects/TestProjests/codeigniter/index.php controller function
这也可以帮助您:https://ellislab.com/codeigniter/user-guide/general/cli.html
public_html/TestProject/...
路径几乎可以肯定是用户目录中的相对路径。您可以在 cron 中使用wget
来访问 url:
* * * * * wget http://www.example.com/cronscript > /dev/null
更改上面的时间,让它随心所欲地运行
使用文件名的系统路径和空格后的函数名称来执行,它应该看起来像这样:
php /var/www/path/to/controller/classFile functionName