简体   繁体   English

CodeIgniter中的Cron工作不起作用

[英]Cron job in CodeIgniter doesn't work

I set up my cron job like this. 我像这样设置我的Cron工作。 Here is my command 这是我的命令

php public_html/project_name/index.php cron cronExec

cronExec is a function in my controller name cron. cronExec是我的控制器名称cron中的一个函数。 That will save a data into my database. 这样会将数据保存到我的数据库中。

Anyways, does index.php really need to put in command? 无论如何,index.php真的需要输入命令吗? I set my config.php into this code: 我将config.php设置为以下代码:

$config['index_page'] = ''; 

It should execute every minute I already set it in my cron job but it didn't work. 它应该在我已经在我的cron工作中设置的每分钟执行一次,但是没有用。

If you are using Linux server, try below method 如果您使用的是Linux服务器,请尝试以下方法

In cli type following, 在cli类型中,

crontab -e

It will open corntab configuration file in a editor, Then insert following line and save it. 它将在编辑器中打开corntab配置文件,然后插入以下行并保存。

*/60 * * * * wget -O /dev/null http://YourLocalhost/PathToYourFunction

This URL will execute by your server every 1 minute interval. 服务器将每隔1分钟执行一次此URL。

您需要为index.php设置完整的绝对路径。

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

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